Skip to content

Commit f4bb78f

Browse files
authored
Merge pull request #754 from microsoft/copilot/sub-pr-747-another-one
Fix off-by-one errors in IP and port range calculations for Test-Assessment.25395
2 parents 6244d6b + 6b15741 commit f4bb78f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/powershell/tests/Test-Assessment.25395.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function Test-Assessment-25395 {
6666
$end = [System.Net.IPAddress]::Parse($matches[2]).GetAddressBytes()
6767
[array]::Reverse($start)
6868
[array]::Reverse($end)
69-
return (([BitConverter]::ToUInt32($end,0) - [BitConverter]::ToUInt32($start,0)) -gt 255)
69+
return (([BitConverter]::ToUInt32($end,0) - [BitConverter]::ToUInt32($start,0) + 1) -gt 256)
7070
}
7171
return $false
7272
}
@@ -84,7 +84,7 @@ function Test-Assessment-25395 {
8484
$BroadPortRangeThreshold = 10
8585

8686
if ($Port -eq '1-65535') { return $true }
87-
if ($Port -match '^(\d+)-(\d+)$' -and (([int]$matches[2] - [int]$matches[1]) -gt $BroadPortRangeThreshold)) { return $true }
87+
if ($Port -match '^(\d+)-(\d+)$' -and (([int]$matches[2] - [int]$matches[1] + 1) -gt $BroadPortRangeThreshold)) { return $true }
8888
return $false
8989
}
9090

0 commit comments

Comments
 (0)