]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Integer overflows in readelf get_data
authorAlan Modra <amodra@gmail.com>
Wed, 7 Aug 2019 14:07:49 +0000 (23:37 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 7 Aug 2019 14:46:05 +0000 (00:16 +0930)
commit7c1c1904bedb8f873731651b420a23f573785728
treedfd8977ec0d6f14abbc5986fde3bc90ba105a26a
parentf927cc8faff0d2e39561c90f5182ebe99b2f77f6
Integer overflows in readelf get_data

I noticed the test for overflow of amt = size * nmemb in get_data
wasn't effective.  An obvious example of nmemb = 3 and size = half max
value overflows but doesn't result in amt < nmemb.  This patch fixes
this problem and reports a size truncation or overflow rather than out
of memory in more cases.

* readelf.c (get_data): Improve overflow checks.
binutils/ChangeLog
binutils/readelf.c