diff options
author | Mark Wielaard <mark@klomp.org> | 2018-06-12 12:22:13 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-06-17 00:56:05 +0200 |
commit | cfe65047ad96500a8786625ef949099ec5671774 (patch) | |
tree | 7d9d8c3778881299e6a8366d5d83d8ab11300027 /src/readelf.c | |
parent | 29a3395004643c4e412a47cec5de10f63c23f13c (diff) | |
download | elfutils-cfe65047ad96500a8786625ef949099ec5671774.tar.gz |
readelf: Make sure print_form_data always consumes DW_FORM_strx[1234] data.
Found by afl-fuzz. When printing DW_FORM_strx[1234] data eu-readelf didn't
increase readp which meant eu-readelf would keep printing the same line
dirs or files encoded with strx[1234] names. This meant that for insane
large dir or file counts eu-readelf would just keep printing endlessly
because we never reached and of the .debug_line buffer.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'src/readelf.c')
-rw-r--r-- | src/readelf.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/readelf.c b/src/readelf.c index 720d7f3f..a6173806 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -8074,9 +8074,9 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp, { Dwarf_Off idx; if (offset_len == 8) - idx = read_8ubyte_unaligned_inc (dbg, strreadp); + idx = read_8ubyte_unaligned (dbg, strreadp); else - idx = read_4ubyte_unaligned_inc (dbg, strreadp); + idx = read_4ubyte_unaligned (dbg, strreadp); data = dbg->sectiondata[IDX_debug_str]; if (data == NULL || idx >= data->d_size @@ -8093,25 +8093,25 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp, case DW_FORM_strx1: if (readendp - readp < 1) goto invalid_data; - val = *readp; + val = *readp++; goto strx_val; case DW_FORM_strx2: if (readendp - readp < 2) goto invalid_data; - val = read_2ubyte_unaligned (dbg, readp); + val = read_2ubyte_unaligned_inc (dbg, readp); goto strx_val; case DW_FORM_strx3: if (readendp - readp < 3) goto invalid_data; - val = read_3ubyte_unaligned (dbg, readp); + val = read_3ubyte_unaligned_inc (dbg, readp); goto strx_val; case DW_FORM_strx4: if (readendp - readp < 4) goto invalid_data; - val = read_4ubyte_unaligned (dbg, readp); + val = read_4ubyte_unaligned_inc (dbg, readp); goto strx_val; default: |