Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1110-dec_term-avoid-integer-overflow-for-LIST_E...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1110-dec_term-avoid-integer-overflow-for-LIST_EXT.patch of Package erlang
From 2ac0aede4cf48c0eea401562b2e94e4baf45dfe2 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson <mikpelinux@gmail.com> Date: Sun, 6 Nov 2022 17:56:53 +0100 Subject: [PATCH] dec_term: avoid integer overflow for LIST_EXT - use unsigned type for the length n - perform mutiplication by 2 in wider type Fixes #6439 --- erts/emulator/beam/external.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c index 63d7d32487..b2ce5c68eb 100644 --- a/erts/emulator/beam/external.c +++ b/erts/emulator/beam/external.c @@ -4182,37 +4182,39 @@ dec_term_atom_common: *objp = NIL; break; case LIST_EXT: - n = get_int32(ep); + { + Uint32 nu = get_uint32(ep); ep += 4; - if (n == 0) { + if (nu == 0) { next = objp; break; } *objp = make_list(hp); - hp += 2 * n; + hp += 2 * (Uint) nu; objp = hp - 2; objp[0] = (Eterm) (objp+1); objp[1] = (Eterm) next; next = objp; objp -= 2; - n--; + nu--; if (ctx) { - if (reds < n) { + if ((Uint) reds < nu) { ASSERT(reds > 0); ctx->state = B2TDecodeList; - ctx->u.dc.remaining_n = n - reds; - n = reds; + ctx->u.dc.remaining_n = nu - reds; + nu = reds; } - reds -= n; + reds -= nu; } - while (n > 0) { + while (nu > 0) { objp[0] = (Eterm) next; objp[1] = make_list(next); next = objp; objp -= 2; - n--; + nu--; } break; + } case STRING_EXT: n = get_int16(ep); ep += 2; -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor