]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Check there are any header bytes in rnglists
authorMark Wielaard <mark@klomp.org>
Sat, 11 Jul 2026 15:23:36 +0000 (17:23 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 11 Jul 2026 15:23:36 +0000 (17:23 +0200)
We tried to read the rnglists 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 (__libdw_cu_ranges_base): Check before initial
unit_length read.

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

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

index 5e1029bd2ac2444399ada817cc9dd20c2c4ffb5d..25391396ff6b17711dc8be49cb53df0a1b6682d1 100644 (file)
@@ -1373,6 +1373,8 @@ __libdw_cu_ranges_base (Dwarf_CU *cu)
              const unsigned char *const dataend
                = (unsigned char *) data->d_buf + data->d_size;
 
+             if (unlikely (readp > dataend - 4))
+               goto no_header;
              uint64_t unit_length = read_4ubyte_unaligned_inc (dbg, readp);
              unsigned int offset_size = 4;
              if (unlikely (unit_length == 0xffffffff))