Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Jul 2019 14:19:19 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r349804 - stable/12/contrib/elftoolchain/elfcopy
Message-ID:  <201907071419.x67EJJT0034473@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907071419.x67EJJT0034473>