From 67c9eb276d5fe55b6ef09abce7f589b20938605c Mon Sep 17 00:00:00 2001 From: turekt <32360115+turekt@users.noreply.github.com> Date: Mon, 14 Dec 2020 19:54:08 +0000 Subject: [PATCH] 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. --- disasm/ndisasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disasm/ndisasm.c b/disasm/ndisasm.c index 01e0c5577..4d34b21ad 100644 --- a/disasm/ndisasm.c +++ b/disasm/ndisasm.c @@ -297,7 +297,7 @@ int main(int argc, char **argv) p = q = buffer; nextsync = next_sync(offset, &synclen); do { - uint32_t to_read = buffer + sizeof(buffer) - p; + int32_t to_read = buffer + sizeof(buffer) - p; if ((nextsync || synclen) && to_read > nextsync - offset - (p - q)) to_read = nextsync - offset - (p - q);