aboutsummaryrefslogtreecommitdiff
path: root/posix/tst-gnuglob-skeleton.c
diff options
context:
space:
mode:
Diffstat (limited to 'posix/tst-gnuglob-skeleton.c')
-rw-r--r--posix/tst-gnuglob-skeleton.c9
1 files changed, 8 insertions, 1 deletions
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 })"