]> git.ipfire.org Git - thirdparty/nftables.git/commit
netlink: Fix printing of zero-length prefixes
authorPhil Sutter <phil@nwl.cc>
Thu, 9 May 2019 11:35:39 +0000 (13:35 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 9 May 2019 15:19:50 +0000 (17:19 +0200)
commit6b88377e03ba6cd11bbe37241e8a0f9feb5bbac4
tree7fe23df206783f1ed2f4ef1776515127e2ac8ffe
parent993e4282a9981a4bb03b9a8952587724b08d6a50
netlink: Fix printing of zero-length prefixes

When delinearizing, an all-zero mask didn't qualify as prefix. Therefore
a statement:

| ip daddr 0.0.0.0/0

would be printed as:

| ip daddr & 0.0.0.0 == 0.0.0.0

To fix this, expr_mask_is_prefix() must return true if the initial 1-bit
search fails (the given value must be zero in this case). Additionally,
a shortcut is needed in conversion algorithm of expr_mask_to_prefix()
to not turn the zero prefix into a 1 by accident.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink_delinearize.c