From 49d52061f759ff39f15ecf7aeb94204927acf476 Mon Sep 17 00:00:00 2001 From: Phireh Date: Sat, 23 Sep 2023 22:01:35 +0200 Subject: [PATCH] fix: use correct amount of bytes in guard of DIE read loop --- main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index f8cb041..13eb37a 100644 --- a/main.cpp +++ b/main.cpp @@ -165,7 +165,8 @@ void parse_debuginfo_section(const void *file) uint64_t code; fprintf(stdout, ".debug_info offset for first DIE: %#x\n", ((uint64_t)p - (uint64_t)file)); // TODO: 32bit size - for (; ((uint64_t)p - (uint64_t)cuh) < cuh->unit_length - 12;) + // TODO: unit_length is supposed to be 4/12 Bytes + for (; ((uint64_t)p - (uint64_t)cuh) < cuh->unit_length + sizeof(compilation_unit_header_t) - 12;) { p += decode_leb128((uint8_t*)p, &code);