diff options
author | Mark Wielaard <mark@klomp.org> | 2020-07-05 00:33:38 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2020-07-19 14:17:19 +0200 |
commit | 49c200b7c7731d1ca12b465c20afa4c1475e671c (patch) | |
tree | 23137429e5f8941c9734f8e2256ab4b5f5a0ebf5 /src/unstrip.c | |
parent | f9915d3f1947e6bcf9102329500626bd8e74bdd3 (diff) | |
download | elfutils-49c200b7c7731d1ca12b465c20afa4c1475e671c.tar.gz |
libdwfl, src: Replace some asserts with proper check or error messages.
library code really shouldn't assert and for utilities a proper
error message is better than crashing with an assert.
https://sourceware.org/bugzilla/show_bug.cgi?id=26176
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'src/unstrip.c')
-rw-r--r-- | src/unstrip.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/unstrip.c b/src/unstrip.c index 9b8c09a1..a855038a 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -500,7 +500,8 @@ adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr, error (EXIT_FAILURE, 0, "Symbol table cannot have zero sh_entsize"); const size_t nsym = symshdr->sh_size / symshdr->sh_entsize; const size_t onent = shdr->sh_size / shdr->sh_entsize; - assert (data->d_size == shdr->sh_size); + if (data->d_size != shdr->sh_size) + error (EXIT_FAILURE, 0, "HASH section has inconsistent size"); #define CONVERT_HASH(Hash_Word) \ { \ @@ -509,7 +510,8 @@ adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const GElf_Shdr *shdr, const size_t nchain = old_hash[1]; \ const Hash_Word *const old_bucket = &old_hash[2]; \ const Hash_Word *const old_chain = &old_bucket[nbucket]; \ - assert (onent == 2 + nbucket + nchain); \ + if (onent != 2 + nbucket + nchain) \ + error (EXIT_FAILURE, 0, "HASH section has inconsistent entsize"); \ \ const size_t nent = 2 + nbucket + nsym; \ Hash_Word *const new_hash = xcalloc (nent, sizeof new_hash[0]); \ @@ -2469,8 +2471,7 @@ match_module (Dwfl_Module *mod, const char *file; const char *check = dwfl_module_info (mod, NULL, NULL, NULL, NULL, NULL, &file, NULL); - assert (check == name); - if (file == NULL) + if (check == NULL || strcmp (check, name) != 0 || file == NULL) return DWARF_CB_OK; name = file; |