mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-02-17 17:19:35 +08:00
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>
This commit is contained in:
parent
661f723d39
commit
b756372b06
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user