Index: lib/libc/sys/clock_gettime.2 =================================================================== --- lib/libc/sys/clock_gettime.2 +++ lib/libc/sys/clock_gettime.2 @@ -134,6 +134,8 @@ .It Bq Er EINVAL The .Fa clock_id +or +.Fa timespec argument was not a valid value. .It Bq Er EPERM Index: lib/libc/sys/gettimeofday.2 =================================================================== --- lib/libc/sys/gettimeofday.2 +++ lib/libc/sys/gettimeofday.2 @@ -110,6 +110,10 @@ The following error codes may be set in .Va errno : .Bl -tag -width Er +.It Bq Er EINVAL +The supplied +.Fa timeval +value is invalid. .It Bq Er EPERM A user other than the super-user attempted to set the time. .El Index: sys/kern/kern_time.c =================================================================== --- sys/kern/kern_time.c +++ sys/kern/kern_time.c @@ -398,7 +398,8 @@ return (error); if (clock_id != CLOCK_REALTIME) return (EINVAL); - if (ats->tv_nsec < 0 || ats->tv_nsec >= 1000000000) + if (ats->tv_nsec < 0 || ats->tv_nsec >= 1000000000 + || ats->tv_sec < 0) return (EINVAL); /* XXX Don't convert nsec->usec and back */ TIMESPEC_TO_TIMEVAL(&atv, ats); @@ -618,7 +619,8 @@ return (error); /* Verify all parameters before changing time. */ if (tv) { - if (tv->tv_usec < 0 || tv->tv_usec >= 1000000) + if (tv->tv_usec < 0 || tv->tv_usec >= 1000000 + || tv->tv_sec < 0) return (EINVAL); error = settime(td, tv); }