]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - binutils/readelf.c
asan: readelf: process_mips_specific buffer overflow
authorAlan Modra <amodra@gmail.com>
Thu, 11 Jun 2020 03:57:50 +0000 (13:27 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 11 Jun 2020 04:24:46 +0000 (13:54 +0930)
commitd0c4e7802dae311d71059d0e2114150a5e09acf1
tree9824b956af903fa6348c339ab5163d0d22db6af9
parentec16513e310c2bfe4ff6d7e01b371858c6756c9e
asan: readelf: process_mips_specific buffer overflow

DT_MIPS_OPTIONS is not a regular array as assumed by readelf.  This
patch corrects that assumption, and to do so easily, makes various
internal (host byte order) structs the same size as external (target
byte order) structs.

include/
* elf/mips.h (Elf32_RegInfo): Use fixed width integer types.
(Elf64_Internal_RegInfo, Elf_Internal_Options): Likewise.
binutils/
* readelf.c (process_mips_specific): Assert size of internal
types match size of external types, and simplify allocation of
internal buffer.  Catch possible integer overflow when sanity
checking option size.  Don't assume options are a regular array.
Sanity check reginfo option against option size.  Use PRI macros
when printing.
binutils/ChangeLog
binutils/readelf.c
include/ChangeLog
include/elf/mips.h