fix: use unsigned right shift for subnet mask calculation

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Nick Taylor
2026-02-13 23:51:38 -05:00
committed by Peter Steinberger
parent 9228ef0856
commit a7ba8cc553

View File

@@ -180,7 +180,7 @@ function ipMatchesCIDR(ip: string, cidr: string): boolean {
(subnetParts[0] << 24) | (subnetParts[1] << 16) | (subnetParts[2] << 8) | subnetParts[3];
// Create mask and compare
const mask = prefixLen === 0 ? 0 : 0xffffffff << (32 - prefixLen);
const mask = prefixLen === 0 ? 0 : (-1 >>> (32 - prefixLen)) << (32 - prefixLen);
return (ipInt & mask) === (subnetInt & mask);
}