[nasm:master] ndisasm: Stack buffer overflow fix

nasm-bot for turekt 32360115+turekt at users.noreply.github.com
Mon Nov 7 17:12:15 PST 2022


Commit-ID:  a9faae3e0ba95d0b6d910365989f1e35c08ac8ee
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=a9faae3e0ba95d0b6d910365989f1e35c08ac8ee
Author:     turekt <32360115+turekt at users.noreply.github.com>
AuthorDate: Mon, 14 Dec 2020 19:54:08 +0000
Committer:  Cyrill Gorcunov <gorcunov at gmail.com>
CommitDate: Wed, 5 May 2021 00:30:55 +0300

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 at gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>


---
 disasm/ndisasm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/disasm/ndisasm.c b/disasm/ndisasm.c
index 01e0c557..4d34b21a 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);


More information about the Nasm-commits mailing list