aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/utimensat.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-07-10 17:54:42 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-10-16 14:19:23 -0300
commit01f33a9acc8f02ae6a6dd1efe366c28c825af8a8 (patch)
tree236ba1e8d84c076d7f26c496f9ed159668b71ce4 /sysdeps/unix/sysv/linux/utimensat.c
parentcb49c65bb5581b5ca6122898716aad1f075982d8 (diff)
downloadglibc-01f33a9acc8f02ae6a6dd1efe366c28c825af8a8.tar
glibc-01f33a9acc8f02ae6a6dd1efe366c28c825af8a8.tar.gz
glibc-01f33a9acc8f02ae6a6dd1efe366c28c825af8a8.tar.bz2
glibc-01f33a9acc8f02ae6a6dd1efe366c28c825af8a8.zip
linux: Fix time64 support for futimesat
The generic implementation does not support time64 and the default one return overflow for invalid tv_sec with UTIME_NOW / UTIME_OMIT (which is valid since tv_sec in such cases is ignored by the kernel). Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'sysdeps/unix/sysv/linux/utimensat.c')
-rw-r--r--sysdeps/unix/sysv/linux/utimensat.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/utimensat.c b/sysdeps/unix/sysv/linux/utimensat.c
index ea23c2f051..aef34916e8 100644
--- a/sysdeps/unix/sysv/linux/utimensat.c
+++ b/sysdeps/unix/sysv/linux/utimensat.c
@@ -36,9 +36,13 @@ __utimensat64_helper (int fd, const char *file,
if (ret == 0 || errno != ENOSYS)
return ret;
+ /* For UTIME_NOW and UTIME_OMIT the value of tv_sec field is ignored. */
+# define TS_VALID(ns) \
+ ((((ns).tv_nsec == UTIME_NOW || (ns).tv_nsec == UTIME_OMIT) \
+ || in_time_t_range ((ns).tv_sec)))
+
if (tsp64 != NULL
- && (! in_time_t_range (tsp64[0].tv_sec)
- || ! in_time_t_range (tsp64[1].tv_sec)))
+ && (!TS_VALID (tsp64[0]) || !TS_VALID (tsp64[1])))
{
__set_errno (EOVERFLOW);
return -1;