svn commit: r349804 - stable/12/contrib/elftoolchain/elfcopy

Mark Johnston markj at FreeBSD.org
Sun Jul 7 14:19:20 UTC 2019


Author: markj
Date: Sun Jul  7 14:19:19 2019
New Revision: 349804
URL: https://svnweb.freebsd.org/changeset/base/349804

Log:
  MFC r349730:
  elfcopy: Clear errors after fetching the shstrtab index.

Modified:
  stable/12/contrib/elftoolchain/elfcopy/sections.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- stable/12/contrib/elftoolchain/elfcopy/sections.c	Sun Jul  7 12:15:24 2019	(r349803)
+++ stable/12/contrib/elftoolchain/elfcopy/sections.c	Sun Jul  7 14:19:19 2019	(r349804)
@@ -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-all mailing list