ipfw - Fix broken mixed network and host IP specifications in ip tables
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 12 Mar 2022 01:09:48 +0000 (17:09 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 12 Mar 2022 01:09:48 +0000 (17:09 -0800)
commit7a85cb47e3735b43552cc1131e9fe4fcb27b5428
tree51b12f15a9438f93909da22885d87a0c03b3c0cf
parent409b1644ff50c8442c3dc042f8e2554543861394
ipfw - Fix broken mixed network and host IP specifications in ip tables

* ipfw improperly assumes that the netmask sin_len is pre-zero'd, but
  prior table entries on the same command line which specify a network
  mask will leave the field non-zero for later host entries also specified
  on the command line:

        ipfw table 1 add 10.0.0.0/8 192.0.2.1     # 2^24 + 1 addresses

# ipfw table 1 print
10.0.0.0/8
192.0.0.0/8 <--- wrong

* Fix the issue by properly initializing netmask.sin_len to 0 when a
  host IP is specified.

Submitted-by: Martin Neitzel <neitzel@marshlabs.gaertner.de>
sbin/ipfw/ipfw2.c