From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1792) id A94B63858C27; Thu, 3 Aug 2023 20:47:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A94B63858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691095643; bh=w/pZOhF92VkJh3VSJWx1k11otsOTo8+AnuXn5BBBllI=; h=From:To:Subject:Date:From; b=tCVbRtRziHJt94llg9I0pN06tlv7B/AHSlFapzGoDUknke4YoxeCzDSOJYx6rTHx1 a89LOt6BDqVfE4sPq1nWWz/ZP3NDxPjJ/IqjMCcYHl+Gsj3NBniVSDwQ+oj9IhCNvp i2pRWu+dTKkHguHANxYL66q198e7tb75UHRAVO+M= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Samuel Thibault To: glibc-cvs@sourceware.org Subject: [glibc] tst-*glob*: Do not check d_name size X-Act-Checkin: glibc X-Git-Author: Samuel Thibault X-Git-Refname: refs/heads/master X-Git-Oldrev: d97a12704bca5c2c326d856a69cd847c89784ae9 X-Git-Newrev: 5e4435f960bb681cbea853fb41043fabeeaea1b4 Message-Id: <20230803204723.A94B63858C27@sourceware.org> Date: Thu, 3 Aug 2023 20:47:23 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5e4435f960bb681cbea853fb41043fabeeaea1b4 commit 5e4435f960bb681cbea853fb41043fabeeaea1b4 Author: Samuel Thibault Date: Thu Aug 3 21:15:39 2023 +0200 tst-*glob*: Do not check d_name size 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. Diff: --- 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 })"