Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F105327493
D34848.id104956.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D34848.id104956.diff
View Options
Index: sys/compat/linux/linux_time.c
===================================================================
--- sys/compat/linux/linux_time.c
+++ sys/compat/linux/linux_time.c
@@ -142,7 +142,7 @@
linux_to_native_timespec(struct timespec *ntp, struct l_timespec *ltp)
{
- if (ltp->tv_sec < 0 || ltp->tv_nsec < 0 || ltp->tv_nsec > 999999999)
+ if (!timespecvalid_interval(ltp))
return (EINVAL);
ntp->tv_sec = ltp->tv_sec;
ntp->tv_nsec = ltp->tv_nsec;
@@ -165,7 +165,7 @@
linux_to_native_timespec64(struct timespec *ntp, struct l_timespec64 *ltp64)
{
- if (ltp64->tv_sec < 0 || ltp64->tv_nsec < 0 || ltp64->tv_nsec > 999999999)
+ if (!timespecvalid_interval(ltp64))
return (EINVAL);
ntp->tv_sec = ltp64->tv_sec;
ntp->tv_nsec = ltp64->tv_nsec;
Index: sys/kern/kern_event.c
===================================================================
--- sys/kern/kern_event.c
+++ sys/kern/kern_event.c
@@ -1930,8 +1930,7 @@
rsbt = 0;
if (tsp != NULL) {
- if (tsp->tv_sec < 0 || tsp->tv_nsec < 0 ||
- tsp->tv_nsec >= 1000000000) {
+ if (!timespecvalid_interval(tsp)) {
error = EINVAL;
goto done_nl;
}
Index: sys/kern/kern_time.c
===================================================================
--- sys/kern/kern_time.c
+++ sys/kern/kern_time.c
@@ -411,7 +411,7 @@
return (error);
if (clock_id != CLOCK_REALTIME)
return (EINVAL);
- if (ats->tv_nsec < 0 || ats->tv_nsec >= NS_PER_SEC || ats->tv_sec < 0)
+ if (!timespecvalid_interval(ats))
return (EINVAL);
if (!allow_insane_settime &&
(ats->tv_sec > 8000ULL * 365 * 24 * 60 * 60 ||
@@ -1644,7 +1644,7 @@
itimespecfix(struct timespec *ts)
{
- if (ts->tv_sec < 0 || ts->tv_nsec < 0 || ts->tv_nsec >= NS_PER_SEC)
+ if (!timespecvalid_interval(ts))
return (EINVAL);
if ((UINT64_MAX - ts->tv_nsec) / NS_PER_SEC < ts->tv_sec)
return (EINVAL);
Index: sys/kern/kern_umtx.c
===================================================================
--- sys/kern/kern_umtx.c
+++ sys/kern/kern_umtx.c
@@ -3772,9 +3772,7 @@
error = copyin(uaddr, tsp, sizeof(*tsp));
if (error == 0) {
- if (tsp->tv_sec < 0 ||
- tsp->tv_nsec >= 1000000000 ||
- tsp->tv_nsec < 0)
+ if (!timespecvalid_interval(tsp))
error = EINVAL;
}
return (error);
@@ -3793,8 +3791,7 @@
error = copyin(uaddr, tp, sizeof(*tp));
if (error != 0)
return (error);
- if (tp->_timeout.tv_sec < 0 ||
- tp->_timeout.tv_nsec >= 1000000000 || tp->_timeout.tv_nsec < 0)
+ if (!timespecvalid_interval(&tp->_timeout))
return (EINVAL);
return (0);
}
@@ -4640,9 +4637,7 @@
error = copyin(uaddr, &ts32, sizeof(ts32));
if (error == 0) {
- if (ts32.tv_sec < 0 ||
- ts32.tv_nsec >= 1000000000 ||
- ts32.tv_nsec < 0)
+ if (!timespecvalid_interval(&ts32))
error = EINVAL;
else {
CP(ts32, *tsp, tv_sec);
@@ -4666,8 +4661,7 @@
error = copyin(uaddr, &t32, sizeof(t32));
if (error != 0)
return (error);
- if (t32._timeout.tv_sec < 0 ||
- t32._timeout.tv_nsec >= 1000000000 || t32._timeout.tv_nsec < 0)
+ if (!timespecvalid_interval(&t32._timeout))
return (EINVAL);
TS_CP(t32, *tp, _timeout);
CP(t32, *tp, _flags);
@@ -4704,9 +4698,7 @@
error = copyin(uaddr, &ts32, sizeof(ts32));
if (error == 0) {
- if (ts32.tv_sec < 0 ||
- ts32.tv_nsec >= 1000000000 ||
- ts32.tv_nsec < 0)
+ if (!timespecvalid_interval(&ts32))
error = EINVAL;
else {
CP(ts32, *tsp, tv_sec);
@@ -4730,8 +4722,7 @@
error = copyin(uaddr, &t32, sizeof(t32));
if (error != 0)
return (error);
- if (t32._timeout.tv_sec < 0 ||
- t32._timeout.tv_nsec >= 1000000000 || t32._timeout.tv_nsec < 0)
+ if (!timespecvalid_interval(&t32._timeout))
return (EINVAL);
TS_CP(t32, *tp, _timeout);
CP(t32, *tp, _flags);
Index: sys/kern/sys_generic.c
===================================================================
--- sys/kern/sys_generic.c
+++ sys/kern/sys_generic.c
@@ -1501,9 +1501,7 @@
precision = 0;
if (tsp != NULL) {
- if (tsp->tv_sec < 0)
- return (EINVAL);
- if (tsp->tv_nsec < 0 || tsp->tv_nsec >= 1000000000)
+ if (!timespecvalid_interval(tsp))
return (EINVAL);
if (tsp->tv_sec == 0 && tsp->tv_nsec == 0)
sbt = 0;
Index: sys/sys/time.h
===================================================================
--- sys/sys/time.h
+++ sys/sys/time.h
@@ -404,6 +404,8 @@
(vsp)->tv_nsec += 1000000000L; \
} \
} while (0)
+#define timespecvalid_interval(tsp) ((tsp)->tv_sec >= 0 && \
+ (tsp)->tv_nsec >= 0 && (tsp)->tv_nsec < 1000000000L)
#ifdef _KERNEL
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 15, 11:24 PM (21 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15422003
Default Alt Text
D34848.id104956.diff (4 KB)
Attached To
Mode
D34848: Add timespecvalid macro and use it.
Attached
Detach File
Event Timeline
Log In to Comment