From 01f33a9acc8f02ae6a6dd1efe366c28c825af8a8 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 10 Jul 2020 17:54:42 -0300 Subject: 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 --- sysdeps/unix/sysv/linux/utimensat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sysdeps/unix/sysv/linux/utimensat.c') 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; -- cgit v1.2.3