diff options
author | Mark Wielaard <[email protected]> | 2018-01-25 13:24:19 +0100 |
---|---|---|
committer | Mark Wielaard <[email protected]> | 2018-01-25 13:58:26 +0100 |
commit | e98f032d293a8ea8ea2b25949d7f452603e644d9 (patch) | |
tree | 4d6d4f1f405678affff86b4940d88b9d43e3b24c | |
parent | 1e2c886bb2e1e48dfc592f356ecad7da0a032f0a (diff) |
readelf: Fix crash on reading loc data or range data with bad/no CUs.
In print_debug_ranges_section and print_debug_loc_section we try to
get the associated CU through skip_listptr_hole for the first data data.
If no CU at all can be found (because the .debug_info section was bogus)
this would keep the Dwarf_CU uninitialized causing a crash later on
when it was compared to the last_cu and used because it was unequal.
Fix this by explicitly initializing cu to last_cu (which is NULL on
first use).
Signed-off-by: Mark Wielaard <[email protected]>
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/readelf.c | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 49b0cc03..a0bb7a25 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2018-01-25 Mark Wielaard <[email protected]> + + * readelf.c (print_debug_ranges_section): Initialize cu to last_cu. + (print_debug_loc_section): Likewise. + 2018-01-01 Mark Wielaard <[email protected]> * readelf.c (attr_callback): Use dwarf_form_name for unknown forms. diff --git a/src/readelf.c b/src/readelf.c index 4bdaef20..6c49d305 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -5014,7 +5014,7 @@ print_debug_ranges_section (Dwfl_Module *dwflmod, while (readp < endp) { ptrdiff_t offset = readp - (unsigned char *) data->d_buf; - Dwarf_CU *cu; + Dwarf_CU *cu = last_cu; if (first && skip_listptr_hole (&known_rangelistptr, &listptr_idx, &address_size, NULL, &base, &cu, @@ -7140,7 +7140,7 @@ print_debug_loc_section (Dwfl_Module *dwflmod, while (readp < endp) { ptrdiff_t offset = readp - (unsigned char *) data->d_buf; - Dwarf_CU *cu; + Dwarf_CU *cu = last_cu; if (first && skip_listptr_hole (&known_loclistptr, &listptr_idx, &address_size, &offset_size, &base, |