Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Feb 2020 05:15:35 +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: r357755 - stable/12/contrib/elftoolchain/elfcopy
Message-ID:  <202002110515.01B5FZYg096052@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Feb 11 05:15:35 2020
New Revision: 357755
URL: https://svnweb.freebsd.org/changeset/base/357755

Log:
  MFC r357537, r357538:
  elfcopy: Coverity fixups.

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

Modified: stable/12/contrib/elftoolchain/elfcopy/main.c
==============================================================================
--- stable/12/contrib/elftoolchain/elfcopy/main.c	Tue Feb 11 05:14:36 2020	(r357754)
+++ stable/12/contrib/elftoolchain/elfcopy/main.c	Tue Feb 11 05:15:35 2020	(r357755)
@@ -587,15 +587,19 @@ copy_from_tempfile(const char *src, const char *dst, i
 	if ((tmpfd = open(dst, O_CREAT | O_TRUNC | O_WRONLY, 0755)) < 0)
 		return (-1);
 
-	if (elftc_copyfile(infd, tmpfd) < 0)
+	if (elftc_copyfile(infd, tmpfd) < 0) {
+		(void) close(tmpfd);
 		return (-1);
+	}
 
 	/*
 	 * Remove the temporary file from the file system
 	 * namespace, and close its file descriptor.
 	 */
-	if (unlink(src) < 0)
+	if (unlink(src) < 0) {
+		(void) close(tmpfd);
 		return (-1);
+	}
 
 	(void) close(infd);
 

Modified: stable/12/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- stable/12/contrib/elftoolchain/elfcopy/sections.c	Tue Feb 11 05:14:36 2020	(r357754)
+++ stable/12/contrib/elftoolchain/elfcopy/sections.c	Tue Feb 11 05:15:35 2020	(r357755)
@@ -1092,7 +1092,7 @@ read_section(struct section *s, size_t *size)
 		if (b == NULL)
 			b = malloc(id->d_size);
 		else
-			b = malloc(sz + id->d_size);
+			b = realloc(b, sz + id->d_size);
 		if (b == NULL)
 			err(EXIT_FAILURE, "malloc or realloc failed");
 



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