tst-*glob*: Do not check d_name size
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 3 Aug 2023 19:15:39 +0000 (21:15 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 3 Aug 2023 20:41:45 +0000 (22:41 +0200)
Posix says that d_name is of unspecified size, and sizeof(d_name)
should not be used. It is indeed only 1-byte long in bits/dirent.h. We
can instead explictly provide the actual allocated size to
__strcpy_chk.

posix/tst-glob_lstat_compat.c
posix/tst-gnuglob-skeleton.c

index 937ad77..6559954 100644 (file)
@@ -173,7 +173,7 @@ my_readdir (void *gdir)
 
   dir->d.d_type = filesystem[dir->idx].type;
 
-  strcpy (dir->d.d_name, filesystem[dir->idx].name);
+  __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX);
 
   ++dir->idx;
 
index 557cfcb..998fc2d 100644 (file)
@@ -222,7 +222,7 @@ my_readdir (void *gdir)
 
   dir->d.d_type = filesystem[dir->idx].type;
 
-  strcpy (dir->d.d_name, filesystem[dir->idx].name);
+  __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX);
 
   if (test_verbose > 0)
     printf ("info: my_readdir ({ level: %d, idx: %ld })"