* [COMMITTED] readelf: Fix crash on reading loc data or range data with bad/no CUs.
@ 2018-01-25 13:35 Mark Wielaard
0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2018-01-25 13:35 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
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 <mark@klomp.org>
---
src/ChangeLog | 5 +++++
src/readelf.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 49b0cc0..a0bb7a2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-25 Mark Wielaard <mark@klomp.org>
+
+ * readelf.c (print_debug_ranges_section): Initialize cu to last_cu.
+ (print_debug_loc_section): Likewise.
+
2018-01-01 Mark Wielaard <mark@klomp.org>
* readelf.c (attr_callback): Use dwarf_form_name for unknown forms.
diff --git a/src/readelf.c b/src/readelf.c
index 4bdaef2..6c49d30 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,
--
1.8.3.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-01-25 13:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25 13:35 [COMMITTED] readelf: Fix crash on reading loc data or range data with bad/no CUs Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).