diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-08-30 09:00:04 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2024-02-09 10:29:18 -0300 |
commit | 9920e9108949d8031a61369a4623fa359ee13925 (patch) | |
tree | a0919b48941225fadff930622f5462590e599a91 | |
parent | 95875f9a30e6bd2661287e0a5d38a73ec39540d8 (diff) | |
download | glibc-9920e9108949d8031a61369a4623fa359ee13925.tar glibc-9920e9108949d8031a61369a4623fa359ee13925.tar.gz glibc-9920e9108949d8031a61369a4623fa359ee13925.tar.bz2 glibc-9920e9108949d8031a61369a4623fa359ee13925.zip |
posix: Remove the __strcpy_chk from glob tests
Not all compiler supports the builtin.
-rw-r--r-- | posix/tst-glob_lstat_compat.c | 8 | ||||
-rw-r--r-- | 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 })" |