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:
Mark Johnston 2020-02-04 21:16:41 +00:00
parent 334f09a65b
commit f2530c80db

View File

@ -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");