mqueues: Return EINVAL upon invalid timeout request.
authorStathis Kamperis <beket@dragonflybsd.org>
Thu, 14 Jan 2010 20:06:03 +0000 (22:06 +0200)
committerStathis Kamperis <beket@dragonflybsd.org>
Thu, 14 Jan 2010 20:08:11 +0000 (22:08 +0200)
sys/kern/sys_mqueue.c

index 08347d2..59bdde4 100644 (file)
@@ -277,6 +277,9 @@ abstimeout2timo(struct timespec *ts, int *timo)
        struct timespec tsd;
        int error;
 
+       if (ts->tv_sec < 0 || ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000) {
+               return EINVAL;
+       }
        getnanotime(&tsd);
        timespecsub(ts, &tsd);
        if (ts->tv_sec < 0 || (ts->tv_sec == 0 && ts->tv_nsec <= 0)) {