aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-02-04 21:16:41 +0000
committerMark Johnston <markj@FreeBSD.org>2020-02-04 21:16:41 +0000
commitf2530c80db7b29b95368fce956b3a778f096b368 (patch)
treee643cb0fc2c4590d9535e1e6b910a6d814778e93
parent334f09a65b7ce53bc096e7387ac640d15b8c5737 (diff)
downloadsrc-f2530c80db7b29b95368fce956b3a778f096b368.tar.gz
src-f2530c80db7b29b95368fce956b3a778f096b368.zip
elfcopy: Handle multiple data descriptors properly.
The code clearly meant to resize the buffer in the case where a section was backed by multiple data descriptors. In practice this shouldn't have been a problem since libelf would return a single data descriptor for each section in a newly opened file. CID: 1262522 MFC after: 1 week Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=357537
-rw-r--r--contrib/elftoolchain/elfcopy/sections.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/contrib/elftoolchain/elfcopy/sections.c b/contrib/elftoolchain/elfcopy/sections.c
index 3ffa3858eba5..a3ebfe126721 100644
--- a/contrib/elftoolchain/elfcopy/sections.c
+++ b/contrib/elftoolchain/elfcopy/sections.c
@@ -1137,7 +1137,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");