summaryrefslogtreecommitdiffstats
path: root/libdw/memory-access.h
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-06-12 12:22:13 +0200
committerMark Wielaard <[email protected]>2018-06-17 00:56:05 +0200
commitcfe65047ad96500a8786625ef949099ec5671774 (patch)
tree7d9d8c3778881299e6a8366d5d83d8ab11300027 /libdw/memory-access.h
parent29a3395004643c4e412a47cec5de10f63c23f13c (diff)
readelf: Make sure print_form_data always consumes DW_FORM_strx[1234] data.
Found by afl-fuzz. When printing DW_FORM_strx[1234] data eu-readelf didn't increase readp which meant eu-readelf would keep printing the same line dirs or files encoded with strx[1234] names. This meant that for insane large dir or file counts eu-readelf would just keep printing endlessly because we never reached and of the .debug_line buffer. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libdw/memory-access.h')
-rw-r--r--libdw/memory-access.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/libdw/memory-access.h b/libdw/memory-access.h
index 22918cb9..a39ad6d2 100644
--- a/libdw/memory-access.h
+++ b/libdw/memory-access.h
@@ -362,6 +362,11 @@ read_3ubyte_unaligned (Dwarf *dbg, const unsigned char *p)
}
+#define read_3ubyte_unaligned_inc(Dbg, Addr) \
+ ({ uint32_t t_ = read_2ubyte_unaligned (Dbg, Addr); \
+ Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 3); \
+ t_; })
+
#define read_addr_unaligned_inc(Nbytes, Dbg, Addr) \
(assert ((Nbytes) == 4 || (Nbytes) == 8), \
((Nbytes) == 4 ? read_4ubyte_unaligned_inc (Dbg, Addr) \