svn commit: r357755 - stable/12/contrib/elftoolchain/elfcopy
Mark Johnston
markj at FreeBSD.org
Tue Feb 11 05:15:36 UTC 2020
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");
More information about the svn-src-stable-12
mailing list