diff options
author | Aleksandar Rikalo <arikalo@gmail.com> | 2025-06-20 09:08:07 +0200 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2025-06-20 20:11:03 +0100 |
commit | fcce95b68cbb1fbeb3bdaa1429defc347678fb2b (patch) | |
tree | 53da08a3345aa20b50c53d93926f44f3535c6458 /gdbsupport/print-utils.cc | |
parent | 404285eda06bef2532f2f219eed50ef03f5b608c (diff) | |
download | gdb-fcce95b68cbb1fbeb3bdaa1429defc347678fb2b.zip gdb-fcce95b68cbb1fbeb3bdaa1429defc347678fb2b.tar.gz gdb-fcce95b68cbb1fbeb3bdaa1429defc347678fb2b.tar.bz2 |
gdbsupport: Use xsnprintf() instead of strcat() in print-utils
Theoretically, in functions core_addr_to_string_nz() and
core_addr_to_string(), strcat() can overflow, so use a safe
approach using xsnprintf().
Change-Id: Ib9437450b3634dc35077234f462a03a8640242d4
Diffstat (limited to 'gdbsupport/print-utils.cc')
-rw-r--r-- | gdbsupport/print-utils.cc | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc index a798713..8514720 100644 --- a/gdbsupport/print-utils.cc +++ b/gdbsupport/print-utils.cc @@ -304,8 +304,7 @@ core_addr_to_string (const CORE_ADDR addr) { char *str = get_print_cell (); - strcpy (str, "0x"); - strcat (str, phex (addr)); + xsnprintf (str, PRINT_CELL_SIZE, "0x%s", phex (addr)); return str; } @@ -316,8 +315,7 @@ core_addr_to_string_nz (const CORE_ADDR addr) { char *str = get_print_cell (); - strcpy (str, "0x"); - strcat (str, phex_nz (addr)); + xsnprintf (str, PRINT_CELL_SIZE, "0x%s", phex_nz (addr)); return str; } |