Skip to content

Commit

Permalink
net: prevent /32 ipv4 mask from matching all ips
Browse files Browse the repository at this point in the history
  • Loading branch information
supriyo-biswas committed Jun 11, 2022
1 parent 3987d6b commit 3736cdb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/node_sockaddr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ bool in_network_ipv4(
const SocketAddress& ip,
const SocketAddress& net,
int prefix) {
if (prefix == 32)
return compare_ipv4(ip, net) == SocketAddress::CompareResult::SAME;

uint32_t mask = ((1 << prefix) - 1) << (32 - prefix);

const sockaddr_in* ip_in =
Expand Down

0 comments on commit 3736cdb

Please sign in to comment.