fix: handle malformed ip
Massimo Melina committed
Jun 12, 2024 at 12:44 UTC
66acc6c0068bdbda1eb4987140a435d17fb21aa0
1 file changed
+7
-2
src/misc.ts
+7
-2
@@ -60,8 +60,13 @@ export function makeNetMatcher(mask: string, emptyMaskReturns=false) {
60
else
61
bl.addAddress(address)
62
}
63
- return (ip: string) =>
64
- neg !== bl.check(parseAddress(ip))
63
+ return (ip: string) => {
64
+ try { return neg !== bl.check(parseAddress(ip)) }
65
+ catch {
66
+ console.error("invalid address " + ip)
67
+ return false
68
+ }
69
+ }
70
}
71
72
// can throw ERR_INVALID_ADDRESS