From owner-freebsd-bugs@FreeBSD.ORG Sun Jan 17 17:30:02 2010 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 30DAA1065676 for ; Sun, 17 Jan 2010 17:30:02 +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 E71E68FC25 for ; Sun, 17 Jan 2010 17:30:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o0HHU1Md090517 for ; Sun, 17 Jan 2010 17:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o0HHU1SR090516; Sun, 17 Jan 2010 17:30:01 GMT (envelope-from gnats) Resent-Date: Sun, 17 Jan 2010 17:30:01 GMT Resent-Message-Id: <201001171730.o0HHU1SR090516@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, "Efstratios Karatzas " Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B4A311065693 for ; Sun, 17 Jan 2010 17:20:22 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id A32C88FC16 for ; Sun, 17 Jan 2010 17:20:22 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0HHKMWk002439 for ; Sun, 17 Jan 2010 17:20:22 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o0HHKMKS002438; Sun, 17 Jan 2010 17:20:22 GMT (envelope-from nobody) Message-Id: <201001171720.o0HHKMKS002438@www.freebsd.org> Date: Sun, 17 Jan 2010 17:20:22 GMT From: "Efstratios Karatzas " To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/142912: [patch] nfsstat(1) -w should produce error message if fed a negative value X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jan 2010 17:30:02 -0000 >Number: 142912 >Category: bin >Synopsis: [patch] nfsstat(1) -w should produce error message if fed a negative value >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jan 17 17:30:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Efstratios Karatzas >Release: FreeBSD 8.0-STABLE i386 >Organization: >Environment: FreeBSD Eternal_Crusader 8.0-STABLE FreeBSD 8.0-STABLE #0: Thu Jan 7 04:08:09 EET 2010 root@bt:/usr/obj/usr/src/sys/GENERIC i386 >Description: nfsstat(1) -w should produce an error message and exit when fed a negative numerical value or a non numerical value at all, in which case atoi simply returns 0. This is the way iostat(8) handles this situation. If we do not check for a negative value, then the negative value we are fed becomes an extremely large unsigned int and the thread will sleep(3) for a long time indeed. >How-To-Repeat: > nfsstat -w -1 > nfsstat -w -3049 > nfsstat -w abc >Fix: apply my patch, all we need is a simple check if the value is less than 1. This way an error message also occurs if we could not parse a number, since the return value in that case is 0. version of the file i've used: rcsid[] = "$FreeBSD: src/usr.bin/nfsstat/nfsstat.c,v 1.29 2009/12/13 03:14:06 delphij Exp$"; Patch attached with submission follows: --- nfsstat.c 2010-01-17 18:34:34.000000000 +0200 +++ nfsstat.orig.c 2010-01-17 18:32:38.000000000 +0200 @@ -126,8 +126,6 @@ break; case 'w': interval = atoi(optarg); - if ((int)interval < 1) - errx(1, "wait time < 1"); break; case 'c': clientOnly = 1; >Release-Note: >Audit-Trail: >Unformatted: