summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordds <dds@FreeBSD.org>2006-01-04 00:47:13 +0000
committerdds <dds@FreeBSD.org>2006-01-04 00:47:13 +0000
commit8943d8966224ca449b50514aca813d2e19c1a2ff (patch)
tree4d221d56164d2b7e471804596cbbae2f3c4293e5 /sys
parentec6ef2133d361728c3d2341e83f89ea1f4fe06c1 (diff)
downloadFreeBSD-src-8943d8966224ca449b50514aca813d2e19c1a2ff.zip
FreeBSD-src-8943d8966224ca449b50514aca813d2e19c1a2ff.tar.gz
Replace tv_usec normalization with the return of EINVAL.
This addresses two objections to the previous behavior, and unbreaks the alpha tinderbox build. TODO: update the utimes(2) man page.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_extattr.c30
-rw-r--r--sys/kern/vfs_syscalls.c30
2 files changed, 12 insertions, 48 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index 8939d18..946b81c 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -2713,25 +2713,6 @@ fchown(td, uap)
}
/*
- * Normalize the tv_usec value of t within the allowed range.
- */
-static struct timeval
-normalize_timeval(const struct timeval *t)
-{
- struct timeval n;
-
- if (t->tv_usec >= 0 && t->tv_usec < 1000000)
- return *t;
- n.tv_sec = t->tv_sec + t->tv_usec / 1000000;
- n.tv_usec = t->tv_usec % 1000000;
- if (n.tv_usec < 0) {
- n.tv_sec--;
- n.tv_usec += 1000000;
- }
- return n;
-}
-
-/*
* Common implementation code for utimes(), lutimes(), and futimes().
*/
static int
@@ -2740,7 +2721,7 @@ getutimes(usrtvp, tvpseg, tsp)
enum uio_seg tvpseg;
struct timespec *tsp;
{
- struct timeval tv[2], tvn;
+ struct timeval tv[2];
const struct timeval *tvp;
int error;
@@ -2757,10 +2738,11 @@ getutimes(usrtvp, tvpseg, tsp)
tvp = tv;
}
- tvn = normalize_timeval(&tvp[0]);
- TIMEVAL_TO_TIMESPEC(&tvn, &tsp[0]);
- tvn = normalize_timeval(&tvp[1]);
- TIMEVAL_TO_TIMESPEC(&tvn, &tsp[1]);
+ if (tvp[0].tv_usec < 0 || tvp[0].tv_usec > 999999 ||
+ tvp[1].tv_usec < 0 || tvp[1].tv_usec > 999999)
+ return (EINVAL);
+ TIMEVAL_TO_TIMESPEC(&tvp[0], &tsp[0]);
+ TIMEVAL_TO_TIMESPEC(&tvp[1], &tsp[1]);
}
return (0);
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 8939d18..946b81c 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -2713,25 +2713,6 @@ fchown(td, uap)
}
/*
- * Normalize the tv_usec value of t within the allowed range.
- */
-static struct timeval
-normalize_timeval(const struct timeval *t)
-{
- struct timeval n;
-
- if (t->tv_usec >= 0 && t->tv_usec < 1000000)
- return *t;
- n.tv_sec = t->tv_sec + t->tv_usec / 1000000;
- n.tv_usec = t->tv_usec % 1000000;
- if (n.tv_usec < 0) {
- n.tv_sec--;
- n.tv_usec += 1000000;
- }
- return n;
-}
-
-/*
* Common implementation code for utimes(), lutimes(), and futimes().
*/
static int
@@ -2740,7 +2721,7 @@ getutimes(usrtvp, tvpseg, tsp)
enum uio_seg tvpseg;
struct timespec *tsp;
{
- struct timeval tv[2], tvn;
+ struct timeval tv[2];
const struct timeval *tvp;
int error;
@@ -2757,10 +2738,11 @@ getutimes(usrtvp, tvpseg, tsp)
tvp = tv;
}
- tvn = normalize_timeval(&tvp[0]);
- TIMEVAL_TO_TIMESPEC(&tvn, &tsp[0]);
- tvn = normalize_timeval(&tvp[1]);
- TIMEVAL_TO_TIMESPEC(&tvn, &tsp[1]);
+ if (tvp[0].tv_usec < 0 || tvp[0].tv_usec > 999999 ||
+ tvp[1].tv_usec < 0 || tvp[1].tv_usec > 999999)
+ return (EINVAL);
+ TIMEVAL_TO_TIMESPEC(&tvp[0], &tsp[0]);
+ TIMEVAL_TO_TIMESPEC(&tvp[1], &tsp[1]);
}
return (0);
}
OpenPOWER on IntegriCloud