mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 04:24:43 +00:00
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
This commit is contained in:
committed by
Pedro Alves
parent
404285eda0
commit
fcce95b68c
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user