Skip to content

Commit

Permalink
Fix incorrect check when comparing IPv4 /32 subnet mask (closes nodej…
Browse files Browse the repository at this point in the history
  • Loading branch information
supriyo-biswas committed Jun 11, 2022
1 parent 3987d6b commit fb86113
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 fb86113

Please sign in to comment.