From: Mark Wielaard Date: Sat, 30 May 2015 21:43:11 +0000 (+0200) Subject: libelf: Don't call mempcpy with possible NULL d_buf. X-Git-Tag: elfutils-0.162~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4ad3c4b81c57b36d9837dc81523cfa7950f30a7;p=thirdparty%2Felfutils.git libelf: Don't call mempcpy with possible NULL d_buf. 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 --- diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 5f66135f1..b8c20cc68 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2015-05-30 Mark Wielaard + + * elf32_updatefile.c (updatemmap): Only call mempcpy and update + last_position when d_size is non-zero. + 2015-05-17 Mark Wielaard * elf32_updatefile.c (updatefile): Allocate shdr_data and scns diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c index e90ad47d4..913c3e462 100644 --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -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);