[glibc/azanella/clang] posix: Remove the __strcpy_chk from glob tests
Adhemerval Zanella
azanella@sourceware.org
Wed Apr 17 20:14:07 GMT 2024
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 })"
More information about the Glibc-cvs
mailing list