Skip to content

Commit 8b1806e

Browse files
committed
permissions: Fix incorrect match of IPv4 addr against IPv6
matchnet()'s possible rcs were not fully handled (here, the -1 case). Many thanks to Bernard Buitenhuis for reporting the issue.
1 parent 4bf044a commit 8b1806e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

modules/permissions/hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ int match_address(p_address_node_t *address, struct ip_addr *ip, unsigned int po
239239

240240
if ((address->v.proto == PROTO_NONE || address->v.proto == proto || proto == PROTO_NONE) &&
241241
(address->v.port == PORT_ANY || address->v.port == port || port == PORT_ANY) &&
242-
(ip_addr_cmp(ip, &address->k.subnet.ip) || matchnet(ip, &address->k.subnet))) {
242+
(ip_addr_cmp(ip, &address->k.subnet.ip) || matchnet(ip, &address->k.subnet)>0)) {
243243
if (!address->v.pattern || !pattern) {
244244
LM_DBG("no pattern to match\n");
245245
return 1;
@@ -348,7 +348,7 @@ int pm_hash_find_group(p_address_table_t *table, struct ip_addr *ip, unsigned in
348348
for (address = group->v.address.bucket[address_hash(&group->v.address, &str_ip)]; address;
349349
address = address->next) {
350350
if ((address->v.port == PORT_ANY || address->v.port == port || port == PORT_ANY) &&
351-
(ip_addr_cmp(ip, &address->k.subnet.ip) || matchnet(ip, &address->k.subnet))) {
351+
(ip_addr_cmp(ip, &address->k.subnet.ip) || matchnet(ip, &address->k.subnet)>0)) {
352352
return group->k.group;
353353
}
354354
}

0 commit comments

Comments
 (0)