]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Add sanity check to store_implicit_value
authorMark Wielaard <mark@klomp.org>
Mon, 9 May 2022 16:47:45 +0000 (18:47 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 14 May 2022 13:32:18 +0000 (15:32 +0200)
Don't just skip the block length, but check it is equal to the
op->number that we are going to use as length.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_getlocation.c

index 631f2f2a05e78a2061be78bf6eb8ba119e6ea5be..b254d9cd14d1e60559e93e279444aa708b14e015 100644 (file)
@@ -1,3 +1,7 @@
+2022-05-09  Mark Wielaard  <mark@klomp.org>
+
+       * dwarf_getlocation.c (store_implicit_value): Check block length.
+
 2022-04-16  Mark Wielaard  <mark@klomp.org>
 
        * libdwP.h: Remove atomics.h include.
index 5db3cf97e235e51dffb06df0fa649a1ee4d268a4..d0d7816319695f816ae41adbf86ff954d072eff2 100644 (file)
@@ -147,7 +147,10 @@ store_implicit_value (Dwarf *dbg, void **cache, Dwarf_Op *op)
                                           sizeof (struct loc_block_s), 1);
   const unsigned char *data = (const unsigned char *) (uintptr_t) op->number2;
   /* Skip the block length.  */
-  __libdw_get_uleb128_unchecked (&data);
+  Dwarf_Word length;
+  get_uleb128_unchecked (length, data);
+  if (length != op->number)
+    return -1;
   block->addr = op;
   block->data = (unsigned char *) data;
   block->length = op->number;