From skreuzer@exit2shell.com  Tue Dec 30 15:35:10 2008
Return-Path: <skreuzer@exit2shell.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A84BC106564A
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Dec 2008 15:35:10 +0000 (UTC)
	(envelope-from skreuzer@exit2shell.com)
Received: from slurry.exit2shell.com (64.147.119.38.static.nyinternet.net [64.147.119.38])
	by mx1.freebsd.org (Postfix) with ESMTP id 6F73C8FC08
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Dec 2008 15:35:10 +0000 (UTC)
	(envelope-from skreuzer@exit2shell.com)
Received: from slurry.exit2shell.com (64.147.119.38.static.nyinternet.net [64.147.119.38])
	by slurry.exit2shell.com (8.14.3/8.14.3) with ESMTP id mBUFZ4e3098315
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Dec 2008 10:35:09 -0500 (EST)
	(envelope-from skreuzer@slurry.exit2shell.com)
Received: (from skreuzer@localhost)
	by slurry.exit2shell.com (8.14.3/8.14.3/Submit) id mBUFZ45E098314;
	Tue, 30 Dec 2008 10:35:04 -0500 (EST)
	(envelope-from skreuzer)
Message-Id: <200812301535.mBUFZ45E098314@slurry.exit2shell.com>
Date: Tue, 30 Dec 2008 10:35:04 -0500 (EST)
From: Steve Kreuzer <skreuzer@exit2shell.com>
Reply-To: Steve Kreuzer <skreuzer@exit2shell.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Have nfsstat use strtonum instead of atoi
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         130056
>Category:       bin
>Synopsis:       [patch] have nfsstat(1) use strtonum instead of atoi
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 30 15:40:00 UTC 2008
>Closed-Date:    
>Last-Modified:  Tue Dec 30 22:49:17 UTC 2008
>Originator:     Steve Kreuzer
>Release:        FreeBSD 7.1-PRERELEASE amd64
>Organization:
>Environment:
System: FreeBSD slurry.exit2shell.com 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #3: Mon Nov 24 14:01:09 EST 2008 root@simon.sddi.net:/usr/obj/usr/src/sys/KERNEL amd64

>Description:
	nfsstat uses atoi for -w option. The attached patch will replace aoi
	and use strtonum instead
>How-To-Repeat:
	
>Fix:

--- nfsstat_strtonum_patch.txt begins here ---
Index: nfsstat.c
===================================================================
RCS file: /usr/share/cvs/freebsd/src/usr.bin/nfsstat/nfsstat.c,v
retrieving revision 1.22
diff -u -r1.22 nfsstat.c
--- nfsstat.c	18 Oct 2007 16:38:07 -0000	1.22
+++ nfsstat.c	30 Dec 2008 14:36:56 -0000
@@ -100,6 +100,7 @@
 	int serverOnly = -1;
 	int ch;
 	char *memf, *nlistf;
+	const char *errstr;
 	char errbuf[_POSIX2_LINE_MAX];
 
 	interval = 0;
@@ -116,7 +117,10 @@
 			widemode = 1;
 			break;
 		case 'w':
-			interval = atoi(optarg);
+			interval = (u_int)strtonum(optarg, 0, 1000, &errstr);
+			if (errstr)
+				errx(1, "invalid interval %s: %s",
+					optarg, errstr);
 			break;
 		case 'c':
 			clientOnly = 1;
@@ -141,7 +145,9 @@
 #define	BACKWARD_COMPATIBILITY
 #ifdef	BACKWARD_COMPATIBILITY
 	if (*argv) {
-		interval = atoi(*argv);
+		interval = (u_int)strtonum(*argv, 0, 1000, &errstr);
+		if (errstr)
+			errx(1, "invalid interval %s: %s", *argv, errstr);
 		if (*++argv) {
 			nlistf = *argv;
 			if (*++argv)
--- nfsstat_strtonum_patch.txt ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:
