From: Matthew Dillon Date: Fri, 24 Aug 2012 03:39:05 +0000 (-0700) Subject: kernel - Do not allow the time to be set to { 0, 0 } X-Git-Tag: v3.2.0~274 X-Git-Url: http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/f59ccd4388ba748e851dd1d7c51ddeb3e03382ef kernel - Do not allow the time to be set to { 0, 0 } * The settimeofday() system call now fails with EINVAL if passed a { 0, 0 } tv structure. * No need to allow this case, and it may fix some weird pkgsrc bulkbuild issues. For some reason something in the bulk build calls settimeofday() with { 0, 0 } when linux.ko/linprocfs are not loaded. --- diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 964253f..1bf4105 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -429,13 +429,20 @@ sys_settimeofday(struct settimeofday_args *uap) if ((error = priv_check(td, PRIV_SETTIMEOFDAY))) return (error); - /* Verify all parameters before changing time. */ + /* + * Verify all parameters before changing time. + * + * NOTE: We do not allow the time to be set to 0.0, which also by + * happy coincidence works around a pkgsrc bulk build bug. + */ if (uap->tv) { if ((error = copyin((caddr_t)uap->tv, (caddr_t)&atv, sizeof(atv)))) return (error); if (atv.tv_usec < 0 || atv.tv_usec >= 1000000) return (EINVAL); + if (atv.tv_sec == 0 && atv.tv_usec == 0) + return (EINVAL); } if (uap->tzp && (error = copyin((caddr_t)uap->tzp, (caddr_t)&atz, sizeof(atz))))