public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* New ARI warning Fri Dec  5 01:52:44 UTC 2014
@ 2014-12-05  1:52 GDB Administrator
  2014-12-13 15:29 ` [pushed] Avoid use of sprintf in gdb/utils.c:make_hex_string Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: GDB Administrator @ 2014-12-05  1:52 UTC (permalink / raw)
  To: gdb-patches

755a756
> gdb/utils.c:1127: code: sprintf: Do not use sprintf, instead use xsnprintf or xstrprintf
gdb/utils.c:1127:    p += sprintf (p, ', data[i]);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pushed] Avoid use of sprintf in gdb/utils.c:make_hex_string
  2014-12-05  1:52 New ARI warning Fri Dec 5 01:52:44 UTC 2014 GDB Administrator
@ 2014-12-13 15:29 ` Joel Brobecker
  2014-12-13 18:09   ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2014-12-13 15:29 UTC (permalink / raw)
  To: gdb-patches

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pushed] Avoid use of sprintf in gdb/utils.c:make_hex_string
  2014-12-13 15:29 ` [pushed] Avoid use of sprintf in gdb/utils.c:make_hex_string Joel Brobecker
@ 2014-12-13 18:09   ` Doug Evans
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Evans @ 2014-12-13 18:09 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Sat, Dec 13, 2014 at 7:29 AM, Joel Brobecker <brobecker@adacore.com> wrote:
> 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;
>  }

twas on my todo list.  Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-13 18:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-05  1:52 New ARI warning Fri Dec 5 01:52:44 UTC 2014 GDB Administrator
2014-12-13 15:29 ` [pushed] Avoid use of sprintf in gdb/utils.c:make_hex_string Joel Brobecker
2014-12-13 18:09   ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).