public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/azanella/clang] posix: Remove the __strcpy_chk from glob tests
Date: Thu, 21 Dec 2023 19:00:47 +0000 (GMT)	[thread overview]
Message-ID: <20231221190047.16F32386D60A@sourceware.org> (raw)

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

commit e8f7029902f2b98931db14607540be672b87fe5c
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Aug 30 09:00:04 2023 -0300

    posix: Remove the __strcpy_chk from glob tests
    
    Not all compiler supports the builtin.

Diff:
---
 posix/tst-glob_lstat_compat.c | 8 +++++++-
 posix/tst-gnuglob-skeleton.c  | 9 ++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/posix/tst-glob_lstat_compat.c b/posix/tst-glob_lstat_compat.c
index 6559954247..9e6f9b2c36 100644
--- a/posix/tst-glob_lstat_compat.c
+++ b/posix/tst-glob_lstat_compat.c
@@ -173,7 +173,13 @@ my_readdir (void *gdir)
 
   dir->d.d_type = filesystem[dir->idx].type;
 
-  __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX);
+  {
+    size_t len = strlen (filesystem[dir->idx].name);
+    if (len >= NAME_MAX)
+      FAIL_EXIT1 ("[%s] entry name larger than NAME_MAX (%d)", __func__,
+		  NAME_MAX);
+    memcpy (dir->d.d_name, filesystem[dir->idx].name, len + 1);
+  }
 
   ++dir->idx;
 
diff --git a/posix/tst-gnuglob-skeleton.c b/posix/tst-gnuglob-skeleton.c
index 998fc2d94d..f8888c388c 100644
--- a/posix/tst-gnuglob-skeleton.c
+++ b/posix/tst-gnuglob-skeleton.c
@@ -35,6 +35,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <support/check.h>
 #include <support/test-driver.h>
 
 
@@ -222,7 +223,13 @@ my_readdir (void *gdir)
 
   dir->d.d_type = filesystem[dir->idx].type;
 
-  __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX);
+  {
+    size_t len = strlen (filesystem[dir->idx].name);
+    if (len >= NAME_MAX)
+      FAIL_EXIT1 ("[%s] entry name larger than NAME_MAX (%d)", __func__,
+		  NAME_MAX);
+    memcpy (dir->d.d_name, filesystem[dir->idx].name, len + 1);
+  }
 
   if (test_verbose > 0)
     printf ("info: my_readdir ({ level: %d, idx: %ld })"

             reply	other threads:[~2023-12-21 19:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 19:00 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-17 20:14 Adhemerval Zanella
2024-04-02 16:00 Adhemerval Zanella
2024-02-09 17:38 Adhemerval Zanella
2024-02-07 14:13 Adhemerval Zanella
2024-01-29 18:04 Adhemerval Zanella
2023-09-28 17:58 Adhemerval Zanella
2023-08-30 12:43 Adhemerval Zanella

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=20231221190047.16F32386D60A@sourceware.org \
    --to=azanella@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).