summaryrefslogtreecommitdiff
path: root/libelf
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2014-11-23 21:54:51 +0100
committerMark Wielaard <mjw@redhat.com>2014-11-26 20:24:13 +0100
commitf62658f71fdcf6a51e0dac1bfe4ab082be03bb8a (patch)
tree6778d7af9ebef4a7d6d521880698552e8e837626 /libelf
parent4929606ee8c43154e7b1900d4ffb967f72147aaf (diff)
downloadelfutils-f62658f71fdcf6a51e0dac1bfe4ab082be03bb8a.tar.gz
libelf: Change signed overflow check to unsigned in elf_getdata_rawchunk.
Arithmetic of signed values that overflow causes undefined behaviour Change to explicit unsigned arithmetic overflow check. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libelf')
-rw-r--r--libelf/ChangeLog5
-rw-r--r--libelf/elf_getdata_rawchunk.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 8a115631..68fb0fc1 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,5 +1,10 @@
2014-11-23 Mark Wielaard <mjw@redhat.com>
+ * elf_getdata_rawchunk.c (elf_getdata_rawchunk): Change signed
+ overflow check to unsigned.
+
+2014-11-23 Mark Wielaard <mjw@redhat.com>
+
* note_xlate.h (elf_cvt_note): Copy over any leftover data if
src != dest. The data is probably part of truncated name/desc.
diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c
index f4fbe660..63a9914f 100644
--- a/libelf/elf_getdata_rawchunk.c
+++ b/libelf/elf_getdata_rawchunk.c
@@ -1,5 +1,5 @@
/* Return converted data from raw chunk of ELF file.
- Copyright (C) 2007 Red Hat, Inc.
+ Copyright (C) 2007, 2014 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -57,8 +57,9 @@ elf_getdata_rawchunk (elf, offset, size, type)
return NULL;
}
- if (unlikely (offset < 0 || offset + (off64_t) size < offset
- || offset + size > elf->maximum_size))
+ if (unlikely (offset < 0 || (uint64_t) offset > elf->maximum_size
+ || elf->maximum_size - (uint64_t) offset < size))
+
{
/* Invalid request. */
__libelf_seterrno (ELF_E_INVALID_OP);