gdb/riscv: Fix oob memory access when printing info registers
authorCiaran Woodward <ciaranwoodward@xmos.com>
Fri, 1 Sep 2023 11:13:55 +0000 (12:13 +0100)
committerTom Tromey <tromey@adacore.com>
Tue, 5 Sep 2023 16:33:38 +0000 (10:33 -0600)
commit5cd2b85eba535f3623129f617f331210f62afd76
treed4e3990b35245f8789dc44bd486a806084198a65
parent358be6e72d464349e5146095bdb04b96be5734c1
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>
gdb/riscv-tdep.c