From: Matthias Maennich Date: Sat, 25 Jan 2020 21:40:14 +0000 (+0000) Subject: dwarf-reader: handle binaries with missing symtab X-Git-Tag: upstream/1.7~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4457c10eecd195466484d3265b6a6b8b7e378d5e;p=platform%2Fupstream%2Flibabigail.git dwarf-reader: handle binaries with missing symtab 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 --- diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 555170ec..f6ab72c7 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 00000000..e16c0b84 Binary files /dev/null and b/tests/data/test-read-dwarf/test26-bogus-binary.elf differ diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc index 8f460fef..c33c7729 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} };