diff options
| author | Mark Wielaard <[email protected]> | 2016-07-06 21:31:54 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-07-11 09:58:55 +0200 |
| commit | 8c481b6fc53a1d1f50518896004dc5221862e126 (patch) | |
| tree | 344765fede88dbbce6d4ade17eb8c408c9f07479 /src/unstrip.c | |
| parent | 8b5f017ddf1684e225ef59f9243ef411b2556e9c (diff) | |
unstrip: Fix off by one array access with unstripped_strent.
When configuring with --enable-sanitize-undefined the latest GCC found
an array out of bounds access when running the un-strip-strmerge.sh test.
We keep an array of section names. But skipped section zero, since it
didn't have a name. We should however not actually skip the first array
index (zero) when storing and reading the names.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src/unstrip.c')
| -rw-r--r-- | src/unstrip.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/unstrip.c b/src/unstrip.c index 85e0a1da..adeb5991 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -1761,8 +1761,8 @@ more sections in stripped file than debug file -- arguments reversed?")); GElf_Shdr mem; GElf_Shdr *hdr = gelf_getshdr (sec, &mem); const char *name = get_section_name (i + 1, hdr, shstrtab); - unstripped_strent[i + 1] = ebl_strtabadd (symstrtab, name, 0); - ELF_CHECK (unstripped_strent[i + 1] != NULL, + unstripped_strent[i] = ebl_strtabadd (symstrtab, name, 0); + ELF_CHECK (unstripped_strent[i] != NULL, _("cannot add section name to string table: %s")); } @@ -1785,7 +1785,7 @@ more sections in stripped file than debug file -- arguments reversed?")); Elf_Scn *sec = elf_getscn (unstripped, i + 1); GElf_Shdr mem; GElf_Shdr *hdr = gelf_getshdr (sec, &mem); - shdr->sh_name = ebl_strtaboffset (unstripped_strent[i + 1]); + shdr->sh_name = ebl_strtaboffset (unstripped_strent[i]); update_shdr (sec, hdr); } } |
