summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2022-05-09 18:47:45 +0200
committerMark Wielaard <mark@klomp.org>2022-05-14 15:32:18 +0200
commitededa24fba3a78d97a0e5df2bbe47067906af1d2 (patch)
treee7e3cb34ae3920810297c65bbac940fe293f7f69
parent4a13bd2cf82a401cbe5850fe9a8bd3fcb5b13bfb (diff)
downloadelfutils-ededa24fba3a78d97a0e5df2bbe47067906af1d2.tar.gz
libdw: Add sanity check to store_implicit_value
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>
-rw-r--r--libdw/ChangeLog4
-rw-r--r--libdw/dwarf_getlocation.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 631f2f2a..b254d9cd 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -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.
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index 5db3cf97..d0d78163 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -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;