public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Samuel Thibault <sthibaul@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] tst-*glob*: Do not check d_name size
Date: Thu,  3 Aug 2023 20:47:23 +0000 (GMT)	[thread overview]
Message-ID: <20230803204723.A94B63858C27@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5e4435f960bb681cbea853fb41043fabeeaea1b4

commit 5e4435f960bb681cbea853fb41043fabeeaea1b4
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
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 })"

                 reply	other threads:[~2023-08-03 20:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230803204723.A94B63858C27@sourceware.org \
    --to=sthibaul@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).