From patchwork Wed Aug 9 12:03:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: develop--- via Libc-alpha X-Patchwork-Id: 1819287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=SkTMJV5s; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RLTQ71Zt2z1yfl for ; Wed, 9 Aug 2023 22:09:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1FF00385828E for ; Wed, 9 Aug 2023 12:09:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FF00385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691582989; bh=wN7n1v7eKrSBysXhNdxPU/4AgDYqWWe8g6su49Nc4n4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=SkTMJV5s6Sf+sNIrV7ikKSoVGwq1H90EBaWbU2IAJj/QWmLliWWb7BaS/iD3UU9lY +XzumGz46ZdHtd5gQfak3B6zZ3JbJct+1VPFtCYgigUYik5YhbTfZsZTG7mDdBakyD 6pEcomOzR2GEduOYdia1i4havoTzdVG3EpHb+o+s= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id AE3973858D20 for ; Wed, 9 Aug 2023 12:09:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE3973858D20 Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 379BwgId013292 for ; Wed, 9 Aug 2023 12:09:31 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3scadarg8c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 Aug 2023 12:09:29 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 379BYtLb030361 for ; Wed, 9 Aug 2023 12:04:05 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sa1rnfxs0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 Aug 2023 12:04:05 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 379C42CV44564936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Aug 2023 12:04:02 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 464342004B; Wed, 9 Aug 2023 12:04:02 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8481320043; Wed, 9 Aug 2023 12:04:01 +0000 (GMT) Received: from ltcden2-lp1.aus.stglabs.ibm.com (unknown [9.3.90.43]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 9 Aug 2023 12:04:01 +0000 (GMT) To: libc-alpha@sourceware.org Cc: rajis@linux.ibm.com, Mahesh Bodapati Subject: [PATCH] string: Fix tester build with fortify enable with gcc < 12 Date: Wed, 9 Aug 2023 07:03:44 -0500 Message-Id: <20230809120344.1095219-1-bmahi496@linux.ibm.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -DbVi8_UILKJBV1jcvUXzpNMEAQaSKlK X-Proofpoint-ORIG-GUID: -DbVi8_UILKJBV1jcvUXzpNMEAQaSKlK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-09_10,2023-08-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=754 bulkscore=0 clxscore=1011 impostorscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308090106 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: bmahi496--- via Libc-alpha From: develop--- via Libc-alpha Reply-To: bmahi496@linux.ibm.com Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" From: Mahesh Bodapati When building with fortify enabled, GCC < 12 issues a warning on the fortify strncat 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 12 or newer. Checked on ppc64 and x86_64. --- string/tester.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/string/tester.c b/string/tester.c index f7d4bac5a8..cf3f5ae495 100644 --- a/string/tester.c +++ b/string/tester.c @@ -421,6 +421,12 @@ test_strncat (void) (void) strncat (one, "ij", (size_t)-1); /* set sign bit in count */ equal (one, "abcdghij", 13); + /* When building with fortify enabled, GCC < 12 issues a warning on the + fortify strncat 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 12 or newer. */ +#if __GNUC_PREREQ (12, 0) int ntest = 14; char buf1[80] __attribute__ ((aligned (16))); char buf2[32] __attribute__ ((aligned (16))); @@ -464,6 +470,7 @@ test_strncat (void) } } } +#endif } static void