From bad45984fa96406ed077f976842bee22e334eac5 Mon Sep 17 00:00:00 2001 From: iddq Date: Sat, 10 Feb 2024 12:32:20 +0100 Subject: [PATCH] checks offset value before use --- src/dump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dump.c b/src/dump.c index 8e874cd..112f4a6 100644 --- a/src/dump.c +++ b/src/dump.c @@ -69,7 +69,8 @@ static void dump_file(char *file){ printf("File: %s\n", file); if (magic == 0x5a4d){ /* MZ */ offset = read_dword(0x3c); - magic = read_word(offset); + if (0 < offset && offset < st.st_size-2) + magic = read_word(offset); if (magic == 0x4550) dumppe(offset);