Model: Cap networkPrefixLengths to valid values
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
1f8585443d
commit
3791b2e1b9
|
@ -28,7 +28,13 @@ extension IPAddressRange {
|
||||||
}
|
}
|
||||||
let networkPrefixLengthSubstring = string[indexOfNetworkPrefixLength ..< string.endIndex]
|
let networkPrefixLengthSubstring = string[indexOfNetworkPrefixLength ..< string.endIndex]
|
||||||
if let npl = UInt8(networkPrefixLengthSubstring) {
|
if let npl = UInt8(networkPrefixLengthSubstring) {
|
||||||
networkPrefixLength = npl
|
if (address is IPv4Address) {
|
||||||
|
networkPrefixLength = min(npl, 32)
|
||||||
|
} else if (address is IPv6Address) {
|
||||||
|
networkPrefixLength = min(npl, 128)
|
||||||
|
} else {
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue