From patchwork Fri Jul 21 12:18:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 73046 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 203AD3853546 for ; Fri, 21 Jul 2023 12:19:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 203AD3853546 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689941974; bh=XwD9NRW+kJwHnx1hrZASruTKeP6UP8NBu0ehFn58GqE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eulEAgbEemw433ryAuLWWpI2R7/6bBXI6RXoF7IRHW3knlFpmm4PNZ9KqAMnsp1Ri InKMLlHcvgyCIPFdiXhgaJDjl0ujj/4xcVW87dnplJPzMtW5wJ90Xe1XtmryxlGlog 0ZRn2BJrOJbClGy3dfKI0+o4hEBuXJpshBePMKQA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 48CB6385483D for ; Fri, 21 Jul 2023 12:18:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48CB6385483D Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-6b9ede6195cso1594827a34.3 for ; Fri, 21 Jul 2023 05:18:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689941909; x=1690546709; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XwD9NRW+kJwHnx1hrZASruTKeP6UP8NBu0ehFn58GqE=; b=bex6XaGwl7j+bw5ZrcI2FEk908SO5JOv34WZvgQOi1ubMDj6YqgETEcFWDYfzXeP2D wnGxHj17S/Y3q5sfVWX+LnKBzGxrHThAFBmM64ZuDDZh9o7GPw3pYDQyQbnIBhXLf1ks xYWb55v1SoadT33Vr1x9kA9kOBPjgXRPw7xk3sdi3UvoL4cmODOtDKMSqYmVJVL/LQqR JMyiLzP31PEldAd1+yXPEgwzy9in4su7y3/9UokcwvUSZ2ow79YCMy8B0DVIcxA9D1P7 o54eBX/MajV+XxZxA6HCLpgxWfSlV1zdq5/Ib/sMi3rygbapxTMrfz+5ebL+9GLIhY1W BXxw== X-Gm-Message-State: ABy/qLaR/QdscK0cTvelJmCBmfS1cE27sfssDudpfRbG5Ukq7nuRoXns CMrHzPz4udBc40u+BNNdogXm/Sh9mpWw5jnN8weavA== X-Google-Smtp-Source: APBJJlEyzEhkOCFlosQYHxf/XpkZcZDf7D8VIjJsNwKbgXCUL/iw+RuXAcHidzMfChLwklISlQ14Tw== X-Received: by 2002:a9d:730b:0:b0:6b9:c186:38c7 with SMTP id e11-20020a9d730b000000b006b9c18638c7mr1606765otk.29.1689941909113; Fri, 21 Jul 2023 05:18:29 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:d4d2:3e68:c30b:c219:d30a]) by smtp.gmail.com with ESMTPSA id i14-20020a9d650e000000b006b8a2cd44adsm1296196otl.72.2023.07.21.05.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 05:18:28 -0700 (PDT) To: libc-alpha@sourceware.org, Frederic Berat Subject: [PATCH 3/3] string: Fix tester with fortify enabled Date: Fri, 21 Jul 2023 09:18:17 -0300 Message-Id: <20230721121817.1978446-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230721121817.1978446-1-adhemerval.zanella@linaro.org> References: <20230721121817.1978446-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" If fortify is enabled, the truncated output warning is issued by the wrapper itself: In function ‘strncpy’, inlined from ‘test_strncpy’ at tester.c:505:10: ../string/bits/string_fortified.h:95:10: error: ‘__builtin_strncpy’ destination unchanged after copying no bytes from a string of length 3 [-Werror=stringop-truncation] 95 | return __builtin___strncpy_chk (__dest, __src, __len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 96 | __glibc_objsize (__dest)); | ~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../include/bits/string_fortified.h:1, from ../string/string.h:548, from ../include/string.h:60, from tester.c:33, from inl-tester.c:6: In function ‘strncpy’, inlined from ‘test_strncpy’ at tester.c:505:10: Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell --- string/tester.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/string/tester.c b/string/tester.c index 8de70ad3ce..da42c72141 100644 --- a/string/tester.c +++ b/string/tester.c @@ -26,6 +26,14 @@ #undef __USE_STRING_INLINES #endif +#include +#include + +/* Triggered by strncpy fortify wrapper when it is enabled. */ +#if __GNUC_PREREQ (8, 0) +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-truncation"); +#endif + #include #include #include @@ -33,7 +41,6 @@ #include #include #include -#include /* This file tests a range of corner cases of string functions, including cases where truncation occurs or where sizes specified @@ -45,9 +52,6 @@ DIAG_IGNORE_NEEDS_COMMENT (5.0, "-Wmemset-transposed-args"); DIAG_IGNORE_NEEDS_COMMENT (9, "-Wrestrict"); DIAG_IGNORE_NEEDS_COMMENT (7, "-Wstringop-overflow="); #endif -#if __GNUC_PREREQ (8, 0) -DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-truncation"); -#endif #if __GNUC_PREREQ (11, 0) DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread"); #endif