Bug 142912 - [patch] nfsstat(1) -w should produce error message if fed a negative value
Summary: [patch] nfsstat(1) -w should produce error message if fed a negative value
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 8.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2010-01-17 17:30 UTC by Efstratios Karatzas <gpf.kira@gmail.com>
Modified: 2017-12-31 22:34 UTC (History)
0 users

See Also:

file.diff (279 bytes, patch)
2010-01-17 17:30 UTC, Efstratios Karatzas <gpf.kira@gmail.com>
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Efstratios Karatzas <gpf.kira@gmail.com> 2010-01-17 17:30:01 UTC
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.

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:
How-To-Repeat: > nfsstat -w -1
> nfsstat -w -3049
> nfsstat -w abc
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:12 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped