From owner-freebsd-bugs@FreeBSD.ORG Tue Dec 30 15:40:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E8231065672 for ; Tue, 30 Dec 2008 15:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 355348FC16 for ; Tue, 30 Dec 2008 15:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mBUFe1sr071701 for ; Tue, 30 Dec 2008 15:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mBUFe14U071700; Tue, 30 Dec 2008 15:40:01 GMT (envelope-from gnats) Resent-Date: Tue, 30 Dec 2008 15:40:01 GMT Resent-Message-Id: <200812301540.mBUFe14U071700@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Steve Kreuzer Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A84BC106564A for ; 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 ; 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 ; 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 To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/130056: Have nfsstat use strtonum instead of atoi X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Steve Kreuzer List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 15:40:01 -0000 >Number: 130056 >Category: bin >Synopsis: Have nfsstat 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: >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: