]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Check there are any header bytes in str_offsets_base_off
authorMark Wielaard <mark@klomp.org>
Thu, 9 Jul 2026 20:56:56 +0000 (22:56 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 9 Jul 2026 20:59:03 +0000 (22:59 +0200)
We tried to read the str_offsets header length and only then checked
if there were any bytes left. Make sure to check there are at least 4
bytes for the initial unit length.

* libdw/libdwP.h (str_offsets_base_off): Check before initial
unit_length read.

https://sourceware.org/bugzilla/show_bug.cgi?id=34383

Reported-by: Karan Kurani <karankurani3k@gmail.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/libdwP.h

index 628777b069da4b68bc032460c5928fc62ef68e30..5e1029bd2ac2444399ada817cc9dd20c2c4ffb5d 100644 (file)
@@ -1282,6 +1282,8 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
   uint64_t unit_length;
   uint16_t version;
 
+  if (unlikely (readendp - readp < 4))
+    goto no_header;
   unit_length = read_4ubyte_unaligned_inc (dbg, readp);
   if (unlikely (unit_length == 0xffffffff))
     {