Validate usec ranges in compat_50_netbsd32_select()

Later in the code selcommon() checks for proper timespec, check only
correct usec of timeval before type conversions.
This commit is contained in:
kamil 2019-09-20 15:09:07 +00:00
parent 68ab6f5a50
commit 5404b7cfbe
1 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_compat_50.c,v 1.39 2019/06/27 02:36:27 christos Exp $ */
/* $NetBSD: netbsd32_compat_50.c,v 1.40 2019/09/20 15:09:07 kamil Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.39 2019/06/27 02:36:27 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.40 2019/09/20 15:09:07 kamil Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -140,6 +140,10 @@ compat_50_netbsd32_select(struct lwp *l,
error = copyin(SCARG_P32(uap, tv), &tv32, sizeof(tv32));
if (error != 0)
return error;
if (tv32.tv_usec < 0 || tv32.tv_usec >= 1000000)
return EINVAL;
ats.tv_sec = tv32.tv_sec;
ats.tv_nsec = tv32.tv_usec * 1000;
ts = &ats;