Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/netbsd32 Validate input before converting timeval...



details:   https://anonhg.NetBSD.org/src/rev/d636a6f9f658
branches:  trunk
changeset: 965903:d636a6f9f658
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Oct 05 14:19:53 2019 +0000

description:
Validate input before converting timeval::tv_usec in compat/netbsd32

diffstat:

 sys/compat/netbsd32/netbsd32_compat_50.c |  8 ++++++--
 sys/compat/netbsd32/netbsd32_time.c      |  9 ++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diffs (63 lines):

diff -r 9e0495589bc8 -r d636a6f9f658 sys/compat/netbsd32/netbsd32_compat_50.c
--- a/sys/compat/netbsd32/netbsd32_compat_50.c  Sat Oct 05 12:57:40 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_50.c  Sat Oct 05 14:19:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_compat_50.c,v 1.40 2019/09/20 15:09:07 kamil Exp $    */
+/*     $NetBSD: netbsd32_compat_50.c,v 1.41 2019/10/05 14:19:53 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.40 2019/09/20 15:09:07 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.41 2019/10/05 14:19:53 kamil Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -216,6 +216,10 @@
                return error;
 
        netbsd32_to_timeval50(&atv32, &atv);
+
+       if (atv.tv_usec < 0 || atv.tv_usec >= 1000000)
+               return EINVAL;
+
        TIMEVAL_TO_TIMESPEC(&atv, &ats);
        return settime(p, &ats);
 }
diff -r 9e0495589bc8 -r d636a6f9f658 sys/compat/netbsd32/netbsd32_time.c
--- a/sys/compat/netbsd32/netbsd32_time.c       Sat Oct 05 12:57:40 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_time.c       Sat Oct 05 14:19:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_time.c,v 1.52 2019/09/26 01:30:00 christos Exp $      */
+/*     $NetBSD: netbsd32_time.c,v 1.53 2019/10/05 14:19:53 kamil Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.52 2019/09/26 01:30:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.53 2019/10/05 14:19:53 kamil Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -243,6 +243,10 @@
                return error;
 
        netbsd32_to_timeval(&atv32, &atv);
+
+       if (atv.tv_usec < 0 || atv.tv_usec >= 1000000)
+               return EINVAL;
+
        TIMEVAL_TO_TIMESPEC(&atv, &ats);
        return settime(p, &ats);
 }
@@ -546,4 +550,3 @@
        }
        return copyout(&clock_id, SCARG_P32(uap, clock_id), sizeof(clock_id));
 }
-



Home | Main Index | Thread Index | Old Index