Index: glibc-2.23/sysdeps/mach/hurd/adjtime.c =================================================================== --- glibc-2.23.orig/sysdeps/mach/hurd/adjtime.c +++ glibc-2.23/sysdeps/mach/hurd/adjtime.c @@ -16,9 +16,13 @@ . */ #include +#include #include #include +#define MAX_SEC (INT_MAX / 1000000L - 2) +#define MIN_SEC (INT_MIN / 1000000L + 2) + /* Adjust the current time of day by the amount in DELTA. If OLDDELTA is not NULL, it is filled in with the amount of time adjustment remaining to be done from the last `__adjtime' call. @@ -28,14 +32,22 @@ __adjtime (const struct timeval *delta, { error_t err; mach_port_t hostpriv; + struct timeval dummy = {0, 0}; err = __get_privileged_ports (&hostpriv, NULL); if (err) return __hurd_fail (EPERM); + if (delta->tv_sec > MAX_SEC || delta->tv_sec < MIN_SEC) + return __hurd_fail (EINVAL); + + /* Handle the case when olddelta is NULL, see man adjtime(3) */ + if (olddelta == NULL) + olddelta = &dummy; + err = __host_adjust_time (hostpriv, /* `time_value_t' and `struct timeval' are in - fact identical with the names changed. */ + fact identical with the names changed. */ *(time_value_t *) delta, (time_value_t *) olddelta); __mach_port_deallocate (__mach_task_self (), hostpriv);