[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd,commited 1/4] tst-*glob*: Do not check d_name size
From: |
Samuel Thibault |
Subject: |
[hurd,commited 1/4] tst-*glob*: Do not check d_name size |
Date: |
Thu, 3 Aug 2023 22:48:24 +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 | 2 +-
posix/tst-gnuglob-skeleton.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/posix/tst-glob_lstat_compat.c b/posix/tst-glob_lstat_compat.c
index 937ad77da3..6559954247 100644
--- a/posix/tst-glob_lstat_compat.c
+++ b/posix/tst-glob_lstat_compat.c
@@ -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;
diff --git a/posix/tst-gnuglob-skeleton.c b/posix/tst-gnuglob-skeleton.c
index 557cfcbd2a..998fc2d94d 100644
--- a/posix/tst-gnuglob-skeleton.c
+++ b/posix/tst-gnuglob-skeleton.c
@@ -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 })"
--
2.40.1
- [hurd,commited 0/4] i686-gnu fixes against fortification, Samuel Thibault, 2023/08/03
- [hurd, commited 3/4] tst-realpath-toolong: return "unsupported" when PATH_MAX is undefined, Samuel Thibault, 2023/08/03
- [hurd, commited 2/4] Subject: hurd: Make __realpath return EINVAL on NULL buf, Samuel Thibault, 2023/08/03
- [hurd,commited 1/4] tst-*glob*: Do not check d_name size,
Samuel Thibault <=
- [hurd, commited 4/4] chk: Add and fix hidden builtin definitions for *_chk, Samuel Thibault, 2023/08/03