diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-08-30 09:00:04 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2024-04-17 16:12:41 -0300 |
commit | 8beedb84fede61ed8ad4554bc5de37ee5f13c2e5 (patch) | |
tree | 283cf1c96d56e20b70ca351ec18ea2dd67d9f1a6 | |
parent | b68361a19f5020d24f18f86babc153b094338cf1 (diff) | |
download | glibc-8beedb84fede61ed8ad4554bc5de37ee5f13c2e5.tar.gz glibc-8beedb84fede61ed8ad4554bc5de37ee5f13c2e5.tar.xz glibc-8beedb84fede61ed8ad4554bc5de37ee5f13c2e5.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 })" |