diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2022-04-27 13:40:30 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2022-04-28 09:58:44 -0300 |
commit | 118a2aee07f64d605b6668cbe195c1f44eac6be6 (patch) | |
tree | 3c8cf185865a8797237217743d54e8f01d244d56 /io/tst-lchmod.c | |
parent | 6f043e0ee7e477f50a44024ed0cb579d5e3f511d (diff) | |
download | glibc-118a2aee07f64d605b6668cbe195c1f44eac6be6.zip glibc-118a2aee07f64d605b6668cbe195c1f44eac6be6.tar.gz glibc-118a2aee07f64d605b6668cbe195c1f44eac6be6.tar.bz2 |
linux: Fix fchmodat with AT_SYMLINK_NOFOLLOW for 64 bit time_t (BZ#29097)
The AT_SYMLINK_NOFOLLOW emulation ues the default 32 bit stat internal
calls, which fails with EOVERFLOW if the file constains timestamps
beyond 2038.
Checked on i686-linux-gnu.
Diffstat (limited to 'io/tst-lchmod.c')
-rw-r--r-- | io/tst-lchmod.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/io/tst-lchmod.c b/io/tst-lchmod.c index c644f56..c1c41bd 100644 --- a/io/tst-lchmod.c +++ b/io/tst-lchmod.c @@ -67,9 +67,26 @@ select_path (bool do_relative_path, const char *full_path, const char *relative_ } static void +update_file_time_to_y2038 (const char *fname, int flags) +{ +#ifdef CHECK_TIME64 + /* Y2038 threshold plus 1 second. */ + const struct timespec ts[] = { { 0x80000001LL, 0}, { 0x80000001LL } }; + TEST_VERIFY_EXIT (utimensat (AT_FDCWD, fname, ts, flags) == 0); +#endif +} + +static void test_1 (bool do_relative_path, int (*chmod_func) (int fd, const char *, mode_t, int)) { char *tempdir = support_create_temp_directory ("tst-lchmod-"); +#ifdef CHECK_TIME64 + if (!support_path_support_time64 (tempdir)) + { + puts ("info: test skipped, filesystem does not support 64 bit time_t"); + return; + } +#endif char *path_dangling = xasprintf ("%s/dangling", tempdir); char *path_file = xasprintf ("%s/file", tempdir); @@ -93,9 +110,12 @@ test_1 (bool do_relative_path, int (*chmod_func) (int fd, const char *, mode_t, xsymlink ("loop", path_loop); xsymlink ("target-does-not-exist", path_dangling); + update_file_time_to_y2038 (path_file, 0); + update_file_time_to_y2038 (path_to_file, AT_SYMLINK_NOFOLLOW); + /* Check that the modes do not collide with what we will use in the test. */ - struct stat64 st; + struct stat st; xstat (path_file, &st); TEST_VERIFY ((st.st_mode & 0777) != 1); xlstat (path_to_file, &st); |