Bug 142913 - [patch] netstat(1) -w should produce error message if fed a negative value
Summary: [patch] netstat(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 mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-17 17:40 UTC by Efstratios Karatzas <gpf.kira@gmail.com>
Modified: 2017-12-31 22:34 UTC (History)
0 users

See Also:


Attachments
file.diff (263 bytes, patch)
2010-01-17 17:40 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:40:00 UTC
netstat(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 we will waste a lot of time sleeping before we are finally awaken. 
If I'm not mistaken, we 'll wake up when the timer underflows and eventually turns 0.

Fix: apply my patch. all we need is a check if the value we are fed is a positive integer greater than 1. This way, an error message also occurs if we were not able to parse an integer since atoi(3) returns 0 in that case.

version of the file I used:

__FBSDID("$FreeBSD: src/usr.bin/netstat/main.c,v 1.103 2010/01/11 03:00:17 delphij Exp $");


Patch attached with submission follows:
How-To-Repeat: > netstat -w -1
> netstat -w abc
> netstat -w -30941
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:22 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