PR26430, ASAN: nacl_modify_segment_map elf-nacl.c:164
authorAlan Modra <amodra@gmail.com>
Tue, 25 Aug 2020 05:17:50 +0000 (14:47 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 25 Aug 2020 13:37:10 +0000 (23:07 +0930)
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.

bfd/ChangeLog
bfd/elf-nacl.c

index a24957a8c19f707e9158d8e3f599c0377988a18f..4fc95529ab319927d8b65cedf314851e78408dd2 100644 (file)
@@ -1,3 +1,10 @@
+2020-08-25  Alan Modra  <amodra@gmail.com>
+
+       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.
+
 2020-08-25  Alan Modra  <amodra@gmail.com>
 
        PR 26422
index 3a232dfbb0b9d80589660975c970e7c5673d4410..a7cd827c9174d6a69c1bd41e13ac5542dab42fb9 100644 (file)
@@ -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;
                }
This page took 0.031724 seconds and 4 git commands to generate.