diff options
author | Ciaran Woodward <ciaranwoodward@xmos.com> | 2023-09-01 12:13:55 +0100 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-09-05 10:33:38 -0600 |
commit | 5cd2b85eba535f3623129f617f331210f62afd76 (patch) | |
tree | d4e3990b35245f8789dc44bd486a806084198a65 | |
parent | 358be6e72d464349e5146095bdb04b96be5734c1 (diff) | |
download | binutils-5cd2b85eba535f3623129f617f331210f62afd76.zip binutils-5cd2b85eba535f3623129f617f331210f62afd76.tar.gz binutils-5cd2b85eba535f3623129f617f331210f62afd76.tar.bz2 |
gdb/riscv: Fix oob memory access when printing info registers
If the length of a register name was greater than 15,
print_spaces was called with a negative number, which
prints random data from the heap instead of the requested
number of spaces.
This could happen if a target-description file was used
to specify additional long-named registers.
Fix is simple - don't ask for fewer than 1 space (since
we still want column separation).
Approved-by: Kevin Buettner <kevinb@redhat.com>
-rw-r--r-- | gdb/riscv-tdep.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index ae18eb6..3a2891c 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1145,7 +1145,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, enum tab_stops { value_column_1 = 15 }; gdb_puts (name, file); - print_spaces (value_column_1 - strlen (name), file); + print_spaces (std::max<int> (1, value_column_1 - strlen (name)), file); try { |