Module Name:    src
Committed By:   christos
Date:           Sun Mar 29 17:54:12 UTC 2009

Modified Files:
        src/sys/kern: sys_sig.c

Log Message:
- use itimespecfix to detect invalid timespecs
- use tstohz instead of mstohz to prevent overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/kern/sys_sig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/sys_sig.c
diff -u src/sys/kern/sys_sig.c:1.22 src/sys/kern/sys_sig.c:1.23
--- src/sys/kern/sys_sig.c:1.22	Sun Mar 29 12:23:23 2009
+++ src/sys/kern/sys_sig.c	Sun Mar 29 13:54:12 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_sig.c,v 1.22 2009/03/29 16:23:23 christos Exp $	*/
+/*	$NetBSD: sys_sig.c,v 1.23 2009/03/29 17:54:12 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.22 2009/03/29 16:23:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.23 2009/03/29 17:54:12 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -644,17 +644,16 @@
 	 * Calculate timeout, if it was specified.
 	 */
 	if (SCARG(uap, timeout)) {
-		uint64_t ms;
+		error = (*fetch_timeout)(SCARG(uap, timeout), &ts, sizeof(ts));
+		if (error)
+			return error;
 
-		if ((error = (*fetch_timeout)(SCARG(uap, timeout), &ts, sizeof(ts))))
-			return (error);
+		if ((error = itimespecfix(&ts)) != 0)
+			return error;
 
-		ms = (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
-		timo = mstohz(ms);
-		if (timo == 0 && ts.tv_sec == 0 && ts.tv_nsec > 0)
-			timo = 1;
-		if (timo <= 0)
-			return EINVAL;
+		timo = tstohz(&ts);
+		if (timo == 0 && ts.tv_sec == 0 && ts.tv_nsec != 0)
+			timo++;
 
 		/*
 		 * Remember current uptime, it would be used in

Reply via email to