From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 87965 invoked by alias); 21 Oct 2019 11:27:00 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 87956 invoked by uid 89); 21 Oct 2019 11:27:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-Spam-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mx1.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Date: Tue, 01 Jan 2019 00:00:00 -0000 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Subject: [committed] Work around spurious stringop-overflow warning Message-ID: <20191021112654.GA28869@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2019-q4/txt/msg00021.txt.bz2 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 * 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);