From patchwork Thu Aug 3 20:48:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 73586 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 1F488385DC1D for ; Thu, 3 Aug 2023 20:49:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id B1F4D38582B7 for ; Thu, 3 Aug 2023 20:48:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1F4D38582B7 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 90DBF200FB; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D0SutlgEFqDv; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 249BE200E8; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1qRfFE-0050OK-24; Thu, 03 Aug 2023 22:48:28 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited 1/4] tst-*glob*: Do not check d_name size Date: Thu, 3 Aug 2023 22:48:24 +0200 Message-Id: <20230803204827.1193126-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> References: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Posix says that d_name is of unspecified size, and sizeof(d_name) should not be used. It is indeed only 1-byte long in bits/dirent.h. We can instead explictly provide the actual allocated size to __strcpy_chk. --- posix/tst-glob_lstat_compat.c | 2 +- posix/tst-gnuglob-skeleton.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/posix/tst-glob_lstat_compat.c b/posix/tst-glob_lstat_compat.c index 937ad77da3..6559954247 100644 --- a/posix/tst-glob_lstat_compat.c +++ b/posix/tst-glob_lstat_compat.c @@ -173,7 +173,7 @@ my_readdir (void *gdir) dir->d.d_type = filesystem[dir->idx].type; - strcpy (dir->d.d_name, filesystem[dir->idx].name); + __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX); ++dir->idx; diff --git a/posix/tst-gnuglob-skeleton.c b/posix/tst-gnuglob-skeleton.c index 557cfcbd2a..998fc2d94d 100644 --- a/posix/tst-gnuglob-skeleton.c +++ b/posix/tst-gnuglob-skeleton.c @@ -222,7 +222,7 @@ my_readdir (void *gdir) dir->d.d_type = filesystem[dir->idx].type; - strcpy (dir->d.d_name, filesystem[dir->idx].name); + __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX); if (test_verbose > 0) printf ("info: my_readdir ({ level: %d, idx: %ld })"