diff options
author | Alan Modra <amodra@gmail.com> | 2023-08-03 08:07:54 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-08-03 21:19:54 +0930 |
commit | d191eacb7b5b23872eb955c880e72b811892561a (patch) | |
tree | 0a1e965abedff6833c9ad6dbfa5176eb77f702b3 /binutils | |
parent | b077a53b2b8e4da725f1563e95b55650d61b47e7 (diff) | |
download | fsf-binutils-gdb-d191eacb7b5b23872eb955c880e72b811892561a.zip fsf-binutils-gdb-d191eacb7b5b23872eb955c880e72b811892561a.tar.gz fsf-binutils-gdb-d191eacb7b5b23872eb955c880e72b811892561a.tar.bz2 |
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.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/wrstabs.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/binutils/wrstabs.c b/binutils/wrstabs.c index 234a96f..955b610 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); |