]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libelf: Don't call mempcpy with possible NULL d_buf.
authorMark Wielaard <mjw@redhat.com>
Sat, 30 May 2015 21:43:11 +0000 (23:43 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 5 Jun 2015 12:44:59 +0000 (14:44 +0200)
When d_size is zero d_buf might be NULL. last_position doesn't need to be
updated in that case.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libelf/ChangeLog
libelf/elf32_updatefile.c

index 5f66135f14e4976a888311ef80bc5eafe54442b1..b8c20cc68f1e8e437d671638fc3651b814955685 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-30  Mark Wielaard  <mjw@redhat.com>
+
+       * elf32_updatefile.c (updatemmap): Only call mempcpy and update
+       last_position when d_size is non-zero.
+
 2015-05-17  Mark Wielaard  <mjw@redhat.com>
 
        * elf32_updatefile.c (updatefile): Allocate shdr_data and scns
index e90ad47d458164ca6233b117e8f1755fb3863b83..913c3e4628df62f71bd73a4a60a2a1b1c709f20b 100644 (file)
@@ -367,7 +367,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
 
                        last_position += dl->data.d.d_size;
                      }
-                   else
+                   else if (dl->data.d.d_size != 0)
                      last_position = mempcpy (last_position,
                                               dl->data.d.d_buf,
                                               dl->data.d.d_size);