svn commit: r349730 - head/contrib/elftoolchain/elfcopy
Mark Johnston
markj at FreeBSD.org
Thu Jul 4 15:07:20 UTC 2019
Author: markj
Date: Thu Jul 4 15:07:19 2019
New Revision: 349730
URL: https://svnweb.freebsd.org/changeset/base/349730
Log:
elfcopy: Clear errors after fetching the shstrtab index.
Otherwise a future call to elf_errno() will return a non-zero value.
update_shdr(), for example, treats any errors associated with the ELF
descriptor as fatal. Clear the error per the first example in
elf_errmsg.3.
Convert to elf_getshdrstrndx() while here since elf_getshstrndx() is
apparently deprecated.
Reported by: royger
Reviewed by: emaste
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20852
Modified:
head/contrib/elftoolchain/elfcopy/sections.c
Modified: head/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- head/contrib/elftoolchain/elfcopy/sections.c Thu Jul 4 14:51:44 2019 (r349729)
+++ head/contrib/elftoolchain/elfcopy/sections.c Thu Jul 4 15:07:19 2019 (r349730)
@@ -1403,7 +1403,7 @@ init_shstrtab(struct elfcopy *ecp)
struct section *s;
size_t indx, sizehint;
- if (elf_getshstrndx(ecp->ein, &indx) != 0) {
+ if (elf_getshdrstrndx(ecp->ein, &indx) == 0) {
shstrtab = elf_getscn(ecp->ein, indx);
if (shstrtab == NULL)
errx(EXIT_FAILURE, "elf_getscn failed: %s",
@@ -1413,6 +1413,8 @@ init_shstrtab(struct elfcopy *ecp)
elf_errmsg(-1));
sizehint = shdr.sh_size;
} else {
+ /* Clear the error from elf_getshdrstrndx(3). */
+ (void)elf_errno();
sizehint = 0;
}
More information about the svn-src-head
mailing list