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:
Cyrill Gorcunov 2018-10-29 22:24:25 +03:00
parent 661f723d39
commit b756372b06

View File

@ -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;
}
}