kernel - Return EINVAL on negative timeout to poll()
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 26 May 2015 18:03:32 +0000 (11:03 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 26 May 2015 18:03:32 +0000 (11:03 -0700)
* Return EINVAL if poll() is called with a negative
  timeout, as per manual page.

Submitted-by: stateless
sys/kern/sys_generic.c

index d384589..65097f0 100644 (file)
@@ -1223,6 +1223,8 @@ sys_poll(struct poll_args *uap)
        int error;
 
        if (uap->timeout != INFTIM) {
+               if (uap->timeout < 0)
+                       return (EINVAL);
                ts.tv_sec = uap->timeout / 1000;
                ts.tv_nsec = (uap->timeout % 1000) * 1000 * 1000;
                tsp = &ts;