From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] xtensa: sprintf sanitizer null destination pointer
Date: Thu, 3 Aug 2023 11:51:38 +0000 (GMT) [thread overview]
Message-ID: <20230803115138.BD76638555B4@sourceware.org> (raw)
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);
}
reply other threads:[~2023-08-03 11:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230803115138.BD76638555B4@sourceware.org \
--to=amodra@sourceware.org \
--cc=bfd-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).