Source-Changes-HG archive

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

[src/trunk]: src/sys/kern "tv->tv_sec * hz" could overflow a long. millert@o...



details:   https://anonhg.NetBSD.org/src/rev/7e2bf08c4a19
branches:  trunk
changeset: 539834:7e2bf08c4a19
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Nov 27 04:07:42 2002 +0000

description:
"tv->tv_sec * hz" could overflow a long.  millert@openbsd

diffstat:

 sys/kern/uipc_socket.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r ac514d3f3e5d -r 7e2bf08c4a19 sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c    Wed Nov 27 03:36:04 2002 +0000
+++ b/sys/kern/uipc_socket.c    Wed Nov 27 04:07:42 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket.c,v 1.74 2002/11/27 03:36:04 itojun Exp $  */
+/*     $NetBSD: uipc_socket.c,v 1.75 2002/11/27 04:07:42 itojun Exp $  */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.74 2002/11/27 03:36:04 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.75 2002/11/27 04:07:42 itojun Exp $");
 
 #include "opt_sock_counters.h"
 #include "opt_sosend_loan.h"
@@ -1341,7 +1341,7 @@
                                goto bad;
                        }
                        tv = mtod(m, struct timeval *);
-                       if (tv->tv_sec * hz + tv->tv_usec / tick > SHRT_MAX) {
+                       if (tv->tv_sec > (SHRT_MAX - tv->tv_usec / tick) / hz) {
                                error = EDOM;
                                goto bad;
                        }



Home | Main Index | Thread Index | Old Index