readelf: Don't go past end of line data reading unknown opcode parameters.
authorMark Wielaard <mark@klomp.org>
Tue, 22 Jan 2019 14:55:18 +0000 (15:55 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 22 Jan 2019 17:12:38 +0000 (18:12 +0100)
https://sourceware.org/bugzilla/show_bug.cgi?id=24116

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/readelf.c

index 4ad12a9..0ea106c 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-22  Mark Wielaard  <mark@klomp.org>
+
+       * readelf.c (print_debug_line_section): Check we are not at end of
+       line data when reading parameters for unknown opcodes.
+
 2019-01-20  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (print_debug_line_section): Check terminating NUL byte
index 6bad3bf..e3e699c 100644 (file)
@@ -8845,7 +8845,8 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
                                " unknown opcode with %" PRIu8 " parameters:",
                                standard_opcode_lengths[opcode]),
                      standard_opcode_lengths[opcode]);
-             for (int n = standard_opcode_lengths[opcode]; n > 0; --n)
+             for (int n = standard_opcode_lengths[opcode];
+                  n > 0 && linep < lineendp; --n)
                {
                  get_uleb128 (u128, linep, lineendp);
                  if (n != standard_opcode_lengths[opcode])