0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-09-22 10:43:39 -04:00

ndisasm: Stack buffer overflow fix

Changing the type of `to_read` from `uint32_t` to
`int32_t` makes it aware of negative numbers and fixes
the buffer overflow in ndisasm.

Signed-off-by: T Turek <tureqsec@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
turekt
2020-12-14 19:54:08 +00:00
committed by Cyrill Gorcunov
parent aa2dcdec09
commit a9faae3e0b

View File

@@ -297,7 +297,7 @@ int main(int argc, char **argv)
p = q = buffer; p = q = buffer;
nextsync = next_sync(offset, &synclen); nextsync = next_sync(offset, &synclen);
do { do {
uint32_t to_read = buffer + sizeof(buffer) - p; int32_t to_read = buffer + sizeof(buffer) - p;
if ((nextsync || synclen) && if ((nextsync || synclen) &&
to_read > nextsync - offset - (p - q)) to_read > nextsync - offset - (p - q))
to_read = nextsync - offset - (p - q); to_read = nextsync - offset - (p - q);