diff options
| author | Mark Wielaard <[email protected]> | 2020-11-01 23:45:32 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2020-11-01 23:45:32 +0100 |
| commit | 8dd97a0a871672b3f7a58e1fb50b6f7195d8f32d (patch) | |
| tree | 3a86d4fb1d7abf6966ff94a1e25f13f7e1809c48 /src/unstrip.c | |
| parent | 50a6eeef7d87623faa65126dc3d16c2a8e613aea (diff) | |
| parent | b503c358dde835d8a1ae3ebd4968755ff396f814 (diff) | |
Merge tag 'elfutils-0.182' into mjw/RH-DTSdts-0.182
elfutils 0.182 release
Diffstat (limited to 'src/unstrip.c')
| -rw-r--r-- | src/unstrip.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/unstrip.c b/src/unstrip.c index 9b8c09a1..0257d9cc 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -311,12 +311,18 @@ make_directories (const char *path) if (lastslash == path) return; - char *dir = strndupa (path, lastslash - path); + char *dir = strndup (path, lastslash - path); + if (dir == NULL) + error(EXIT_FAILURE, errno, _("memory exhausted")); + while (mkdir (dir, 0777) < 0 && errno != EEXIST) - if (errno == ENOENT) - make_directories (dir); - else - error (EXIT_FAILURE, errno, _("cannot create directory '%s'"), dir); + { + if (errno == ENOENT) + make_directories (dir); + else + error (EXIT_FAILURE, errno, _("cannot create directory '%s'"), dir); + } + free (dir); } /* Keep track of new section data we are creating, so we can free it @@ -500,7 +506,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 +516,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 +2477,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; |
