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>
unsigned long n;
n = mpz_scan1(expr->value, 0);
+ if (n == ULONG_MAX)
+ return 0;
return mpz_scan0(expr->value, n + 1) - n;
}
n1 = mpz_scan1(expr->value, 0);
if (n1 == ULONG_MAX)
- return false;
+ return true;
n2 = mpz_scan0(expr->value, n1 + 1);
if (n2 < expr->len || n2 == ULONG_MAX)
return false;