readelf: Calculate max_entries instead of needed bytes (and overflowing).
authorMark Wielaard <mark@klomp.org>
Fri, 8 Jun 2018 21:30:37 +0000 (23:30 +0200)
committerMark Wielaard <mark@klomp.org>
Mon, 11 Jun 2018 06:35:51 +0000 (08:35 +0200)
commit305211458a58a99b999639171c55724e3d9b51c0
tree578d201aed35a5e904acd1afcee9bb918f1f65b4
parentb78a3336d9d720515b054f250f105600ddb2bd33
readelf: Calculate max_entries instead of needed bytes (and overflowing).

The afl fuzzer found that we would overflow the needed bytes when
calculating how many index entries would fit in the .debug_loclists
and .debug_rnglists tables. To fix this just calculate the max number
of entries. If the offset entry count is larger than that, do emit
an error, but print up to max_entries of offsets (so the user can
more clearly see what is wrong with their table).

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