aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Donnerhacke <donner@FreeBSD.org>2021-07-03 21:03:07 +0000
committerLutz Donnerhacke <donner@FreeBSD.org>2021-07-03 21:03:07 +0000
commitf28455344483310cfd1aa5c0bdd4d014810c0e32 (patch)
tree7148462c9ed6275118a4ea4462ce39989c7e2fdf
parent24f398e7a153a05a7e94ae8dd623e2b6d28d94eb (diff)
downloadsrc-f28455344483310cfd1aa5c0bdd4d014810c0e32.tar.gz
src-f28455344483310cfd1aa5c0bdd4d014810c0e32.zip
libalias: Fix API bug on initialization
The kernel part of ipfw(8) does initialize LibAlias uncondistionally with an zeroized port range (allowed ports from 0 to 0). During restucturing of libalias, port ranges are used everytime and are therefor initialized with different values than zero. The secondary initialization from ipfw (and probably others) overrides the new default values and leave the instance in an unfunctional state. The obvious solution is to detect such reinitializations and use the new default value instead. MFC after: 3 days
-rw-r--r--sys/netinet/libalias/alias_db.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c
index 9f8c6064d2a7..5b53067705bf 100644
--- a/sys/netinet/libalias/alias_db.c
+++ b/sys/netinet/libalias/alias_db.c
@@ -2048,9 +2048,15 @@ LibAliasSetAliasPortRange(struct libalias *la, u_short port_low,
u_short port_high)
{
LIBALIAS_LOCK(la);
- la->aliasPortLower = port_low;
- /* Add 1 to the aliasPortLength as modulo has range of 1 to n-1 */
- la->aliasPortLength = port_high - port_low + 1;
+ if (port_low) {
+ la->aliasPortLower = port_low;
+ /* Add 1 to the aliasPortLength as modulo has range of 1 to n-1 */
+ la->aliasPortLength = port_high - port_low + 1;
+ } else {
+ /* Set default values */
+ la->aliasPortLower = 0x8000;
+ la->aliasPortLength = 0x8000;
+ }
LIBALIAS_UNLOCK(la);
}