diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 0627878d2ede..7e4a3e703302 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1152,7 +1152,11 @@ bpf_ioctl(struct file *fp, u_long cmd, void *addr) struct timeval *tv = addr; /* Compute number of ticks. */ - if (tv->tv_sec > INT_MAX/hz - 1) { + if (tv->tv_sec < 0 || + tv->tv_usec < 0 || tv->tv_usec >= 1000000) { + error = EINVAL; + break; + } else if (tv->tv_sec > INT_MAX/hz - 1) { d->bd_rtout = INT_MAX; } else { d->bd_rtout = tv->tv_sec * hz @@ -1186,7 +1190,11 @@ bpf_ioctl(struct file *fp, u_long cmd, void *addr) struct timeval50 *tv = addr; /* Compute number of ticks. */ - if (tv->tv_sec > INT_MAX/hz - 1) { + if (tv->tv_sec < 0 || + tv->tv_usec < 0 || tv->tv_usec >= 1000000) { + error = EINVAL; + break; + } else if (tv->tv_sec > INT_MAX/hz - 1) { d->bd_rtout = INT_MAX; } else { d->bd_rtout = tv->tv_sec * hz