summaryrefslogtreecommitdiffstats
path: root/libelf
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2015-05-30 23:43:11 +0200
committerMark Wielaard <mjw@redhat.com>2015-06-05 14:44:59 +0200
commitb4ad3c4b81c57b36d9837dc81523cfa7950f30a7 (patch)
treea453a08bb58408dc648ab7e78f33fbed9f139587 /libelf
parent5ad751b089896fbc5198485080eea5d1a8bd192b (diff)
downloadandroid_external_elfutils-b4ad3c4b81c57b36d9837dc81523cfa7950f30a7.tar.gz
android_external_elfutils-b4ad3c4b81c57b36d9837dc81523cfa7950f30a7.tar.bz2
android_external_elfutils-b4ad3c4b81c57b36d9837dc81523cfa7950f30a7.zip
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 <mjw@redhat.com>
Diffstat (limited to 'libelf')
-rw-r--r--libelf/ChangeLog5
-rw-r--r--libelf/elf32_updatefile.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 5f66135f..b8c20cc6 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -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
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index e90ad47d..913c3e46 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);