From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: [committed] Work around spurious stringop-overflow warning
Date: Tue, 01 Jan 2019 00:00:00 -0000 [thread overview]
Message-ID: <20191021112654.GA28869@delia> (raw)
Hi,
With the previous commit we get with gcc 8 and newer:
...
In function âmake_temp_fileâ,
inlined from âmake_temp_fileâ at dwz.c:12366:1:
dwz.c:12399:3: warning: âstrncpyâ specified bound depends \
on the length of the source argument [-Wstringop-overflow=]
12399 | strncpy (&buf[offset], name, buf_len - offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dwz.c: In function âmake_temp_fileâ:
dwz.c:12384:14: note: length computed here
12384 | name_len = strlen (name);
| ^~~~~~~~~~~~~
...
This is due to a gcc PR 88059 - "Spurious stringop-overflow warning with
strlen, malloc and strncpy".
Work around this gcc PR by using strcpy instead of strncpy.
Committed to trunk.
Thanks,
- Tom
Work around spurious stringop-overflow warning
2019-10-21 Tom de Vries <tdevries@suse.de>
* dwz.c (make_temp_file): Use strcpy instead of strncpy.
---
dwz.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dwz.c b/dwz.c
index e762fb7..e940d91 100644
--- a/dwz.c
+++ b/dwz.c
@@ -12393,13 +12393,13 @@ make_temp_file (const char *name)
return -1;
offset = 0;
- strncpy (&buf[offset], tmpdir, buf_len - offset);
+ strcpy (&buf[offset], tmpdir);
offset += strlen (tmpdir);
- strncpy (&buf[offset], name, buf_len - offset);
+ strcpy (&buf[offset], name);
offset += name_len;
- strncpy (&buf[offset], template_suffix, buf_len - offset);
+ strcpy (&buf[offset], template_suffix);
offset += strlen (template_suffix);
assert (offset == buf_len - 1);
reply other threads:[~2019-10-21 11:27 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=20191021112654.GA28869@delia \
--to=tdevries@suse.de \
--cc=dwz@sourceware.org \
--cc=jakub@redhat.com \
/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).