public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] wrstabs: sprintf sanitizer null destination pointer
@ 2023-08-03 11:51 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-08-03 11:51 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d191eacb7b5b23872eb955c880e72b811892561a

commit d191eacb7b5b23872eb955c880e72b811892561a
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Aug 3 08:07:54 2023 +0930

    wrstabs: sprintf sanitizer null destination pointer
    
    gcc-2.12 seems to be ignoring __attribute__((__returns_nonnull__))
    on xmalloc.
    
            * wrstabs.c (stab_method_type): Use stpcpy rather than sprintf
            or strcat.

Diff:
---
 binutils/wrstabs.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/binutils/wrstabs.c b/binutils/wrstabs.c
index 234a96f98a3..955b610cd59 100644
--- a/binutils/wrstabs.c
+++ b/binutils/wrstabs.c
@@ -1202,17 +1202,21 @@ stab_method_type (void *p, bool domainp, int argcount,
     len += strlen (args[i]);
 
   buf = xmalloc (len);
-
-  sprintf (buf, "#%s,%s", domain, return_type);
+  char *out = buf;
+  *out++ = '#';
+  out = stpcpy (out, domain);
+  *out++ = ',';
+  out = stpcpy (out, return_type);
   free (domain);
   free (return_type);
   for (i = 0; i < argcount; i++)
     {
-      strcat (buf, ",");
-      strcat (buf, args[i]);
+      *out++ = ',';
+      out = stpcpy (out, args[i]);
       free (args[i]);
     }
-  strcat (buf, ";");
+  *out++ = ';';
+  *out = 0;
 
   free (args);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-03 11:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-03 11:51 [binutils-gdb] wrstabs: sprintf sanitizer null destination pointer Alan Modra

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).