From: nasm-bot f. C. G. <gor...@gm...> - 2018-10-29 20:00:14
|
Commit-ID: b756372b0668092f1e189ef097889df0f40dee79 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=b756372b0668092f1e189ef097889df0f40dee79 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Mon, 29 Oct 2018 22:24:25 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 29 Oct 2018 22:25:16 +0300 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 <gor...@gm...> --- asm/rdstrnum.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/asm/rdstrnum.c b/asm/rdstrnum.c index d9d2a69..319f140 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; } } |