From patchwork Thu Jun 5 17:58:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 113758 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 1122D3857729 for ; Thu, 5 Jun 2025 18:05:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1122D3857729 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by sourceware.org (Postfix) with ESMTP id 49678385697E for ; Thu, 5 Jun 2025 17:59:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49678385697E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 49678385697E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4190:8020::34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749146345; cv=none; b=NTkjvuCVdTnOUcnZG64pLqLWjxWbsnjnqBeXIqy9UmBqmP5gcpUyDDIhLAkuUv9L1ekqmD+SKdItarxbzwqpje7iRhaohx20fsKdH5cofDO1h6Ndg/yMlz8dbuktV45H+DhYoeOPYhSerbYbJIH+eHPhXJm34yC9V6PpgSyuE3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749146345; c=relaxed/simple; bh=KZFQsAj6mFGB5LAX2QamAhKG+bceQ8kGHE2CBb+ACXU=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=cyuLuZbVpvSnpvCUROiJMO/KwXXJv7GfdhvTWwIFxtVGc/eYrGjxenWss24EhkG3hvmWEwQoaQm5I9b82vPZbEFswyq7ZvCx/SxVGuSDvCF9HK0i/hCguvLmsuiIVHGGTaFeQlQJqV6XVCyTIdYQ8G1Q2nQVzuLJ9plGYUsCGps= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49678385697E Received: by angie.orcam.me.uk (Postfix, from userid 500) id 8FAED92009E; Thu, 5 Jun 2025 19:58:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 81AD192009B; Thu, 5 Jun 2025 18:58:59 +0100 (BST) Date: Thu, 5 Jun 2025 18:58:59 +0100 (BST) From: "Maciej W. Rozycki" To: libc-alpha@sourceware.org cc: "Maciej W. Rozycki" Subject: [PATCH v2 07/14] stdio-common: Fix macro parameter shadowing in scanf input specifier tests In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-3487.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: "Maciej W. Rozycki" Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: Maciej W. Rozycki The use of the same name for a local variable combined with passing a pointer to it to a nested macro call causes the wrong 'err' variable to be updated in 'read_real', because '&err' is only expanded at '*errp' evaluation. Consequently the variable defined in 'read_real' is set rather than one in its 'verify_input' caller as it would be the case should 'read_real' be a function, leading to invalid input such as: %a:nan:1:3:nan(: to be accepted. Address the issue by renaming the 'err' variable in 'verify_input' to 'errx', causing such input to be correctly rejected: error: ./tst-scanf-format-skeleton.c:242: input line 1: input data format error No test case added as it's a test case issue in the first place. Reviewed-by: Adhemerval Zanella --- No change from v1. --- stdio-common/tst-scanf-format-real.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) glibc-tst-scanf-format-all-real-verify-err-fix.diff Index: glibc/stdio-common/tst-scanf-format-real.h =================================================================== --- glibc.orig/stdio-common/tst-scanf-format-real.h +++ glibc/stdio-common/tst-scanf-format-real.h @@ -73,19 +73,19 @@ ({ \ __label__ out; \ bool match = true; \ - int err = 0; \ + int errx = 0; \ type_t v; \ \ initialize_value (v); \ /* Make sure it's been committed. */ \ __asm__ ("" : : : "memory"); \ - v = read_real (&err); \ - if (err < 0) \ + v = read_real (&errx); \ + if (errx < 0) \ goto out; \ match = compare_real (val, v); \ \ out: \ - if (err || !match) \ + if (errx || !match) \ { \ union \ { \ @@ -104,7 +104,7 @@ out: \ printf ("'\n"); \ } \ \ - *errp = err; \ + *errp = errx; \ match; \ })