The length field could be so big that it would wrap around the next_offset.
We don't really care that length is bogus, but we don't want to use it to
calculate the next offset if it is.
Found by afl-fuzz.
Signed-off-by: Mark Wielaard <mark@klomp.org>
+2018-06-22 Mark Wielaard <mark@klomp.org>
+
+ * dwarf_nextcu.c (__libdw_next_unit): Set next_off to -1 when it would
+ wrap around.
+
2018-06-18 Mark Wielaard <mark@klomp.org>
* dwarf_aggregate_size.c (array_size): New depth argument. Use
or with offset == 8: 2 * 8 - 4 == 12. */
*next_off = off + 2 * offset_size - 4 + length;
+ /* This means that the length field is bogus, but return the CU anyway.
+ We just won't return anything after this. */
+ if (*next_off <= off)
+ *next_off = (Dwarf_Off) -1;
+
return 0;
}