Found by the afl fuzzer. The next offset (after a locview) comes from a
DIE loclist attribute. This could be a bogus value so large it overflows
the buffer and makes us print past the end of buffer.
Signed-off-by: Mark Wielaard <mark@klomp.org>
+2018-06-16 Mark Wielaard <mark@klomp.org>
+
+ * readelf.c (print_debug_loc_section): Make sure next_off doesn't
+ overflow d_buf.
+
2018-06-13 Mark Wielaard <mark@klomp.org>
* readelf.c (die_type_sign_bytes): New function.
listptr_idx);
const unsigned char *locp = readp;
const unsigned char *locendp;
- if (next_off == 0)
+ if (next_off == 0
+ || next_off > (size_t) (endp
+ - (const unsigned char *) data->d_buf))
locendp = endp;
else
locendp = (const unsigned char *) data->d_buf + next_off;