From 3c46a02f5083c4a9c07b563d44b8b6ded6d85bb1 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Sat, 13 Dec 2014 10:19:03 -0500 Subject: [PATCH] Avoid use of sprintf in gdb/utils.c:make_hex_string The use of sprintf is discouraged in GDB. Use xsnprintf instead. gdb/ChangeLog: * utils.c (make_hex_string): Replace use of sprintf by use of xsnprintf. Tested on x86_64-linux. --- gdb/ChangeLog | 5 +++++ gdb/utils.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ac916def8bc..c12de3a0285 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-12-13 Joel Brobecker + + * utils.c (make_hex_string): Replace use of sprintf by use of + xsnprintf. + 2014-12-13 Joel Brobecker * compile/compile-object-load.c (link_callbacks_multiple_definition) diff --git a/gdb/utils.c b/gdb/utils.c index 1ab183c2ce7..ea2b18a801e 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1124,7 +1124,7 @@ make_hex_string (const gdb_byte *data, size_t length) p = result; for (i = 0; i < length; ++i) - p += sprintf (p, "%02x", data[i]); + p += xsnprintf (p, 2, "%02x", data[i]); *p = '\0'; return result; } -- 2.30.2