2018-06-08 Mark Wielaard <mark@klomp.org>
+ * readelf.c (print_debug_rnglists_section): Calculate max_entries
+ instead of needed bytes to prevent overflowing. Always print
+ max_entries (but not more).
+ (print_debug_loclists_section): Likewise.
+
+2018-06-08 Mark Wielaard <mark@klomp.org>
+
* readelf.c (print_debug_line_section): Stop printing directories
and files when we are at the end of the unit data.
const unsigned char *offset_array_start = readp;
if (offset_entry_count > 0)
{
- uint64_t needed = offset_entry_count * offset_size;
- if (unit_length - 8 < needed)
+ uint64_t max_entries = (unit_length - 8) / offset_size;
+ if (offset_entry_count > max_entries)
{
error (0, 0,
gettext ("too many offset entries for unit length"));
- goto next_table;
+ offset_entry_count = max_entries;
}
printf (gettext (" Offsets starting at 0x%" PRIx64 ":\n"),
const unsigned char *offset_array_start = readp;
if (offset_entry_count > 0)
{
- uint64_t needed = offset_entry_count * offset_size;
- if (unit_length - 8 < needed)
+ uint64_t max_entries = (unit_length - 8) / offset_size;
+ if (offset_entry_count > max_entries)
{
error (0, 0,
gettext ("too many offset entries for unit length"));
- goto next_table;
+ offset_entry_count = max_entries;
}
printf (gettext (" Offsets starting at 0x%" PRIx64 ":\n"),