This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[pushed] Avoid use of sprintf in gdb/utils.c:make_hex_string
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Sat, 13 Dec 2014 10:29:43 -0500
- Subject: [pushed] Avoid use of sprintf in gdb/utils.c:make_hex_string
- Authentication-results: sourceware.org; auth=none
- References: <20141205015244 dot GA30467 at sourceware dot org>
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 and pushed.
---
gdb/ChangeLog | 5 +++++
gdb/utils.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ac916de..c12de3a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2014-12-13 Joel Brobecker <brobecker@adacore.com>
+ * utils.c (make_hex_string): Replace use of sprintf by use of
+ xsnprintf.
+
+2014-12-13 Joel Brobecker <brobecker@adacore.com>
+
* compile/compile-object-load.c (link_callbacks_multiple_definition)
(link_callbacks_warning, link_callbacks_einfo): Remove trailing
newline at end of warning message.
diff --git a/gdb/utils.c b/gdb/utils.c
index 1ab183c..ea2b18a 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;
}
--
1.9.1