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: Wed, 17 Apr 2024 20:14:07 +0000 (GMT)	[thread overview]
Message-ID: <20240417201407.335773858404@sourceware.org> (raw)

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

commit 8beedb84fede61ed8ad4554bc5de37ee5f13c2e5
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 6ea3b062f0..70d5c54838 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 145744199b..e6f39455ff 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:[~2024-04-17 20:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 20:14 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
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-12-21 19:00 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=20240417201407.335773858404@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).