From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 1C024385773C; Wed, 26 Jul 2023 14:22:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C024385773C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690381346; bh=IdDtYFdoN+y5n3u6k5LCF6XvKv7jgt7Ae3NVCNWqB3s=; h=From:To:Subject:Date:From; b=QJi1t0jUamoNWd9HFrC65U2t4+QbxJGIkCZo9jEMY6VSggE//bhzpj91YQ8LfVvx+ HAD+Vr1Ee9h1NP3quQN87mcbUszzBCJYB6ICmuweAJ8g45qGNk7v5oHSKMPl5+1Yb0 sYNexZniKX8UHhVFVXY3ioNpf61whjm5gzb9JlBQ= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] string: Fix tester build with fortify enable with gcc 6 X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella Netto X-Git-Refname: refs/heads/master X-Git-Oldrev: dbc4b032dc5c4ef0c46e9de23c46b1698bad4412 X-Git-Newrev: 784ae968113011ce832b1808d4d42369f5d2e320 Message-Id: <20230726142226.1C024385773C@sourceware.org> Date: Wed, 26 Jul 2023 14:22:26 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=784ae968113011ce832b1808d4d42369f5d2e320 commit 784ae968113011ce832b1808d4d42369f5d2e320 Author: Adhemerval Zanella Netto Date: Tue Jul 25 12:16:41 2023 -0300 string: Fix tester build with fortify enable with gcc 6 When building with fortify enabled, GCC 6 issues an warning the fortify wrapper might overflow the destination buffer. However, GCC does not provide a specific flag to disable the warning (the failure is tied to -Werror). So to avoid disable all errors, only enable the check for GCC 7 or newer. Checked on i686-linux-gnu. Reviewed-by: Carlos O'Donell Diff: --- string/tester.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/string/tester.c b/string/tester.c index da42c72141..f7d4bac5a8 100644 --- a/string/tester.c +++ b/string/tester.c @@ -385,8 +385,17 @@ test_strncat (void) (void) strcpy (one, "gh"); (void) strcpy (two, "ef"); + /* When building with fortify enabled, GCC 6 issues an warning the fortify + wrapper might overflow the destination buffer. However, GCC does not + provide a specific flag to disable the warning (the failure is tied to + -Werror). So to avoid disable all errors, only enable the check for + GCC 7 or newer. */ +#if __GNUC_PREREQ (7, 0) (void) strncat (one, two, 99); equal (one, "ghef", 5); /* Basic test encore. */ +#else + equal (one, "gh", 2); +#endif equal (two, "ef", 6); /* Stomped on source? */ (void) strcpy (one, "");