* [PATCH] dwarf-reader: handle binaries with missing symtab
@ 2020-01-01 0:00 Matthias Maennich via libabigail
2020-01-01 0:00 ` Dodji Seketeli
0 siblings, 1 reply; 3+ messages in thread
From: Matthias Maennich via libabigail @ 2020-01-01 0:00 UTC (permalink / raw)
To: libabigail; +Cc: dodji, kernel-team, maennich
A broken elf file might not have a valid symtab. As of now we would hit
an ABG_ASSERT and crash. Let's catch that case and bail out instead.
* src/abg-dwarf-reader.cc (load_symbol_maps_from_symtab_section):
Handle elf file with missing symtab.
* tests/test-read-dwarf.cc (InOutSpec): add test case.
* tests/data/test-read-dwarf/test26-bogus-binary.elf: new test data.
Signed-off-by: Matthias Maennich <maennich@google.com>
---
src/abg-dwarf-reader.cc | 3 ++-
.../data/test-read-dwarf/test26-bogus-binary.elf | Bin 0 -> 200 bytes
tests/test-read-dwarf.cc | 6 ++++++
3 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 tests/data/test-read-dwarf/test26-bogus-binary.elf
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 555170eccdf0..f6ab72c7dabb 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -7396,7 +7396,8 @@ public:
size_t nb_syms = symtab_sheader->sh_size / symtab_sheader->sh_entsize;
Elf_Data* symtab = elf_getdata(symtab_section, 0);
- ABG_ASSERT(symtab);
+ if (!symtab)
+ return false;
GElf_Ehdr elf_header;
ABG_ASSERT(gelf_getehdr(elf_handle(), &elf_header));
diff --git a/tests/data/test-read-dwarf/test26-bogus-binary.elf b/tests/data/test-read-dwarf/test26-bogus-binary.elf
new file mode 100644
index 0000000000000000000000000000000000000000..e16c0b84907c315362bdf8a887468bb0dae0aaf8
GIT binary patch
literal 200
zcmb<-^>JflWMpArWB>vXLl?wgVBmmIU~+W{8xV-GvGMV-0tNp6XW(I|0|EvyAg>OH
z|NV!8d{-C?L^J>Y9}YGEqz4M1e1;u$4BS9AP!wn@gz*a`2NVZ#L5dj||Ns9Dq;LVS
NlEggSq|7`9I{+HKKxzO0
literal 0
HcmV?d00001
diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc
index 8f460fef3f8f..c33c77290850 100644
--- a/tests/test-read-dwarf.cc
+++ b/tests/test-read-dwarf.cc
@@ -259,6 +259,12 @@ InOutSpec in_out_specs[] =
"",
"",
},
+ {
+ "data/test-read-dwarf/test26-bogus-binary.elf",
+ "",
+ "",
+ "",
+ },
// This should be the last entry.
{NULL, NULL, NULL, NULL}
};
--
2.25.0.341.g760bfbb309-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dwarf-reader: handle binaries with missing symtab
2020-01-01 0:00 [PATCH] dwarf-reader: handle binaries with missing symtab Matthias Maennich via libabigail
@ 2020-01-01 0:00 ` Dodji Seketeli
2020-01-01 0:00 ` Matthias Maennich via libabigail
0 siblings, 1 reply; 3+ messages in thread
From: Dodji Seketeli @ 2020-01-01 0:00 UTC (permalink / raw)
To: Matthias Maennich; +Cc: libabigail, kernel-team
Hello Matthias,
Matthias Maennich <maennich@google.com> a écrit:
> A broken elf file might not have a valid symtab. As of now we would hit
> an ABG_ASSERT and crash. Let's catch that case and bail out instead.
>
> * src/abg-dwarf-reader.cc (load_symbol_maps_from_symtab_section):
> Handle elf file with missing symtab.
> * tests/test-read-dwarf.cc (InOutSpec): add test case.
> * tests/data/test-read-dwarf/test26-bogus-binary.elf: new test data.
This is OK to commit to master.
Thanks!
--
Dodji
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dwarf-reader: handle binaries with missing symtab
2020-01-01 0:00 ` Dodji Seketeli
@ 2020-01-01 0:00 ` Matthias Maennich via libabigail
0 siblings, 0 replies; 3+ messages in thread
From: Matthias Maennich via libabigail @ 2020-01-01 0:00 UTC (permalink / raw)
To: Dodji Seketeli; +Cc: libabigail, kernel-team
On Mon, Jan 27, 2020 at 04:21:21PM +0100, Dodji Seketeli wrote:
>Hello Matthias,
>
>Matthias Maennich <maennich@google.com> a écrit:
>
>> A broken elf file might not have a valid symtab. As of now we would hit
>> an ABG_ASSERT and crash. Let's catch that case and bail out instead.
>>
>> * src/abg-dwarf-reader.cc (load_symbol_maps_from_symtab_section):
>> Handle elf file with missing symtab.
>> * tests/test-read-dwarf.cc (InOutSpec): add test case.
>> * tests/data/test-read-dwarf/test26-bogus-binary.elf: new test data.
>
>This is OK to commit to master.
Done. Thanks!
Cheers,
Matthias
>
>Thanks!
>
>--
> Dodji
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-27 15:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01 0:00 [PATCH] dwarf-reader: handle binaries with missing symtab Matthias Maennich via libabigail
2020-01-01 0:00 ` Dodji Seketeli
2020-01-01 0:00 ` Matthias Maennich via libabigail
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).