aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2018-10-29 22:24:25 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2018-10-29 22:25:16 +0300
commitb756372b0668092f1e189ef097889df0f40dee79 (patch)
tree7d6007c622c41c29a86c02d9646ead3e6b23165b
parent661f723d39e03ca6eb05d7376a43ca33db478354 (diff)
downloadnasm-b756372b0668092f1e189ef097889df0f40dee79.tar.gz
nasm-b756372b0668092f1e189ef097889df0f40dee79.tar.xz
nasm-b756372b0668092f1e189ef097889df0f40dee79.zip
rdstrnum: Make sure we dont shift out of bound
Otherwise we may hit underfined behavior. https://bugzilla.nasm.us/show_bug.cgi?id=3392526 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--asm/rdstrnum.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/asm/rdstrnum.c b/asm/rdstrnum.c
index d9d2a69f..319f140a 100644
--- a/asm/rdstrnum.c
+++ b/asm/rdstrnum.c
@@ -55,12 +55,14 @@ int64_t readstrnum(char *str, int length, bool *warn)
for (i = 0; i < length; i++) {
if (charconst & UINT64_C(0xFF00000000000000))
*warn = true;
+ charconst &= ~UINT64_C(0xFF00000000000000);
charconst = (charconst << 8) + (uint8_t)*--str;
}
} else {
for (i = 0; i < length; i++) {
- if (charconst & 0xFF000000UL)
+ if (charconst & UINT32_C(0xFF000000))
*warn = true;
+ charconst &= ~UINT32_C(0xFF000000);
charconst = (charconst << 8) + (uint8_t)*--str;
}
}