diff options
author | Alan Modra <amodra@gmail.com> | 2023-04-19 23:16:47 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-04-20 09:03:53 +0930 |
commit | 329dd2b6fcad4b3f1c4b0d443381f7c68ef18a9f (patch) | |
tree | 94b26ed119aad030db011e3a58711a7e928c1740 /binutils/dwarf.c | |
parent | 3b37f0f1b86cc1fb3ba9cc6d89695109db7f829a (diff) | |
download | binutils-329dd2b6fcad4b3f1c4b0d443381f7c68ef18a9f.zip binutils-329dd2b6fcad4b3f1c4b0d443381f7c68ef18a9f.tar.gz binutils-329dd2b6fcad4b3f1c4b0d443381f7c68ef18a9f.tar.bz2 |
ubsan: signed integer overflow in display_debug_lines_raw
This one was caused by me unnecessarily promoting an "int adv" to
"int64_t adv". The expression overflowing was 4259 + 9223372036854775807
with the left number being unsigned int.
* dwarf.h (DWARF2_Internal_LineInfo): Replace unsigned short
with uint16_t and unsigned char with uint8_t. Make li_line_base
an int8_t.
* dwarf.c (display_debug_lines_raw): Revert "adv" back to an int.
Diffstat (limited to 'binutils/dwarf.c')
-rw-r--r-- | binutils/dwarf.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 1001a11..8a20bf2 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -4670,7 +4670,7 @@ display_debug_lines_raw (struct dwarf_section * section, while (data < end_of_sequence) { unsigned char op_code; - int64_t adv; + int adv; uint64_t uladv; printf (" [0x%08tx]", data - start); @@ -4717,7 +4717,7 @@ display_debug_lines_raw (struct dwarf_section * section, } adv = (op_code % linfo.li_line_range) + linfo.li_line_base; state_machine_regs.line += adv; - printf (_(" and Line by %" PRId64 " to %d"), + printf (_(" and Line by %d to %d"), adv, state_machine_regs.line); if (verbose_view || state_machine_regs.view) printf (_(" (view %u)\n"), state_machine_regs.view); @@ -4782,7 +4782,7 @@ display_debug_lines_raw (struct dwarf_section * section, case DW_LNS_advance_line: READ_SLEB (adv, data, end); state_machine_regs.line += adv; - printf (_(" Advance Line by %" PRId64 " to %d\n"), + printf (_(" Advance Line by %d to %d\n"), adv, state_machine_regs.line); break; @@ -4802,7 +4802,7 @@ display_debug_lines_raw (struct dwarf_section * section, case DW_LNS_negate_stmt: adv = state_machine_regs.is_stmt; adv = ! adv; - printf (_(" Set is_stmt to %" PRId64 "\n"), adv); + printf (_(" Set is_stmt to %d\n"), adv); state_machine_regs.is_stmt = adv; break; |