diff options
author | Mark Wielaard <mjw@redhat.com> | 2015-09-03 10:50:58 +0200 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2015-09-03 10:50:58 +0200 |
commit | b00a4fa78779ff0f304fa6cb34d49622679c86d4 (patch) | |
tree | fb79c2b93b99634391ac54652e1df5ff60b2a674 /src/ChangeLog | |
parent | a74bdbddd5cd03f6bb633455d8c3b5f6baaf92b5 (diff) | |
download | android_external_elfutils-b00a4fa78779ff0f304fa6cb34d49622679c86d4.tar.gz android_external_elfutils-b00a4fa78779ff0f304fa6cb34d49622679c86d4.tar.bz2 android_external_elfutils-b00a4fa78779ff0f304fa6cb34d49622679c86d4.zip |
readelf: handle_core_item large right shift triggers undefined behaviour.
The problem is this:
int n = ffs (w);
w >>= n;
The intent is to shift away up to (and including) the first least
significant bit in w. But w is an unsigned int, so 32 bits. And the
least significant bit could be bit 32 (ffs counts from 1). Unfortunately
a right shift equal to (or larger than) the length in bits of the left
hand operand is undefined behaviour. We expect w to be zero afterwards.
Which would terminate the while loop in the function. But since it is
undefined behaviour anything can happen. In this case, what will actually
happen is that w is unchanged, causing an infinite loop...
gcc -fsanitize=undefined will catch and warn about this when w = 0x80000000
https://bugzilla.redhat.com/show_bug.cgi?id=1259259
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'src/ChangeLog')
-rw-r--r-- | src/ChangeLog | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5be10750..66f7ead1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2015-09-03 Mark Wielaard <mjw@redhat.com> + + * readelf.c (handle_core_item): Handle right shift >= 32 bits. + 2015-08-11 Mark Wielaard <mjw@redhat.com> * elflint.c (check_sections): When gnuld and a NOBITS section falls |