Bug 58410

Summary: /bin/ipcalc input bugs
Product: [Retired] Red Hat Linux Reporter: Steve Bonneville <sbonnevi>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-01-24 06:58:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Steve Bonneville 2002-01-16 02:26:02 UTC
Three related input parsing bugs with /bin/ipcalc:

1) CIDR short-form.

If a user attempts to use ipcalc by specifying a network/prefix pair (i.e.,
10/8) rather than ip-address/prefix (i.e. 10.0.0.0/8), strange results may
occur.

                network (-n)    broadcast (-b)
 172.0.0.0/8    172.0.0.0       172.255.255.255         (CORRECT)
 172/8          0.0.0.0         0.255.255.255           (INCORRECT)

 172.16.0.0/16  172.16.0.0      172.16.255.255          (CORRECT)
 172.16/16      172.0.0.0       172.0.255.255           (INCORRECT)

 172.16.10.0/24 172.16.10.0     172.16.10.255           (CORRECT)
 172.16.10/24   172.16.0.0      172.16.0.255            (INCORRECT)

Either ipcalc should compute addresses in network/prefix correctly, or it should
reject input in that form.

2) Input checking: CIDR prefix *and* netmask!

Only the -m option complains if a user attempts to give both a CIDR prefix *and*
a subnet mask on the command line.  If the input is so perverse that they
*differ*, the subnet mask takes precedence.

 # ipcalc -n 172.16.1.0/24 255.255.0.0
 NETWORK=172.16.0.0
 # ipcalc -b 172.16.1.0/24 255.255.0.0
 BROADCAST=172.16.255.255
 # ipcalc -p 172.16.1.0/24 255.255.0.0
 PREFIX=16

This input should be rejected outright.

3) (cosmetic bug) ipcalc <IPaddress>/<prefix> silence.

If ipcalc is given an ip-address/prefix but no options, nothing happens. 
If it's given an ip-address and netmask but no options, the usage message is
output.

The usage message should be output in both circumstances.

Comment 1 Bill Nottingham 2002-04-12 22:54:37 UTC
Fixed in 6.63-1.