aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-nacl.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-25 14:47:50 +0930
committerAlan Modra <amodra@gmail.com>2020-08-25 23:07:10 +0930
commit0c1438eb15a31098ba42427e0f48e4e5cc6bfe0b (patch)
treebc4dfae000def74dd1d01c4e540eaaa3798f175f /bfd/elf-nacl.c
parent250dd99fc92bac670691b66363dd71dccb22b10d (diff)
downloadgdb-0c1438eb15a31098ba42427e0f48e4e5cc6bfe0b.zip
gdb-0c1438eb15a31098ba42427e0f48e4e5cc6bfe0b.tar.gz
gdb-0c1438eb15a31098ba42427e0f48e4e5cc6bfe0b.tar.bz2
PR26430, ASAN: nacl_modify_segment_map elf-nacl.c:164
PR 26430 * elf-nacl.c (nacl_modify_segment_map): Correct alloc size and amount copied for elf_segment_map defined with one element sections array.
Diffstat (limited to 'bfd/elf-nacl.c')
-rw-r--r--bfd/elf-nacl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/bfd/elf-nacl.c b/bfd/elf-nacl.c
index 3a232df..a7cd827 100644
--- a/bfd/elf-nacl.c
+++ b/bfd/elf-nacl.c
@@ -156,13 +156,13 @@ nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
secdata->this_hdr.sh_addr = sec->vma;
secdata->this_hdr.sh_size = sec->size;
- newseg = bfd_alloc (abfd,
- sizeof *newseg + ((seg->count + 1)
- * sizeof (asection *)));
+ newseg
+ = bfd_alloc (abfd, (sizeof (*newseg)
+ + seg->count * sizeof (asection *)));
if (newseg == NULL)
return FALSE;
- memcpy (newseg, seg,
- sizeof *newseg + (seg->count * sizeof (asection *)));
+ memcpy (newseg, seg, (sizeof (*newseg) - sizeof (asection *)
+ + seg->count * sizeof (asection *)));
newseg->sections[newseg->count++] = sec;
*m = seg = newseg;
}