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
This commit is contained in:
parent
334f09a65b
commit
f2530c80db
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357537
@ -1137,7 +1137,7 @@ read_section(struct section *s, size_t *size)
|
|||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
b = malloc(id->d_size);
|
b = malloc(id->d_size);
|
||||||
else
|
else
|
||||||
b = malloc(sz + id->d_size);
|
b = realloc(b, sz + id->d_size);
|
||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
err(EXIT_FAILURE, "malloc or realloc failed");
|
err(EXIT_FAILURE, "malloc or realloc failed");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user