From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] dlltool: sprintf sanitizer null destination pointer
Date: Thu, 3 Aug 2023 11:51:18 +0000 (GMT) [thread overview]
Message-ID: <20230803115118.73CAB3857701@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e2e7c5261311fd7d557769a73e1fbc496cd56d23
commit e2e7c5261311fd7d557769a73e1fbc496cd56d23
Author: Alan Modra <amodra@gmail.com>
Date: Thu Aug 3 08:15:12 2023 +0930
dlltool: sprintf sanitizer null destination pointer
* dlltool.c (gen_lib_file): Avoid bogus sanitizer error.
Diff:
---
binutils/dlltool.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 142d43aff81..efa54f1bd72 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -3089,20 +3089,22 @@ gen_lib_file (int delay)
if (dontdeltemps < 2)
{
char *name;
+ size_t stub_len = strlen (TMP_STUB);
- name = xmalloc (strlen (TMP_STUB) + 10);
+ name = xmalloc (stub_len + 10);
+ memcpy (name, TMP_STUB, stub_len);
for (i = 0; (exp = d_exports_lexically[i]); i++)
{
/* Don't delete non-existent stubs for PRIVATE entries. */
if (exp->private)
continue;
- sprintf (name, "%s%05d.o", TMP_STUB, i);
+ sprintf (name + stub_len, "%05d.o", i);
if (unlink (name) < 0)
/* xgettext:c-format */
non_fatal (_("cannot delete %s: %s"), name, strerror (errno));
if (ext_prefix_alias)
{
- sprintf (name, "%s%05d.o", TMP_STUB, i + PREFIX_ALIAS_BASE);
+ sprintf (name + stub_len, "%05d.o", i + PREFIX_ALIAS_BASE);
if (unlink (name) < 0)
/* xgettext:c-format */
non_fatal (_("cannot delete %s: %s"), name, strerror (errno));
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=20230803115118.73CAB3857701@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).