* [binutils-gdb] xtensa: 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=ebfd369c3e9c18318c46d4ddc3ad016905d975ea
commit ebfd369c3e9c18318c46d4ddc3ad016905d975ea
Author: Alan Modra <amodra@gmail.com>
Date: Thu Aug 3 08:56:24 2023 +0930
xtensa: sprintf sanitizer null destination pointer
* config/tc-xtensa.c (xtensa_add_config_info): Use auto buffer
rather than malloc. Use sprintf return value.
Diff:
---
gas/config/tc-xtensa.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index fd3ed067659..025376be9a9 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -8979,16 +8979,15 @@ static void
xtensa_add_config_info (void)
{
asection *info_sec;
- char *data, *p;
+ char data[100];
+ char *p;
int sz;
info_sec = subseg_new (".xtensa.info", 0);
bfd_set_section_flags (info_sec, SEC_HAS_CONTENTS | SEC_READONLY);
- data = XNEWVEC (char, 100);
- sprintf (data, "USE_ABSOLUTE_LITERALS=%d\nABI=%d\n",
- XSHAL_USE_ABSOLUTE_LITERALS, xtensa_abi_choice ());
- sz = strlen (data) + 1;
+ sz = 1 + sprintf (data, "USE_ABSOLUTE_LITERALS=%d\nABI=%d\n",
+ XSHAL_USE_ABSOLUTE_LITERALS, xtensa_abi_choice ());
/* Add enough null terminators to pad to a word boundary. */
do
@@ -9015,8 +9014,6 @@ xtensa_add_config_info (void)
/* Finally, write the descriptor. */
p = frag_more (sz);
memcpy (p, data, sz);
-
- free (data);
}
^ 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] xtensa: 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).