fix(http.sys): correctly parse port values in range [32768:65535] #62506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix HTTP.SYS parsing the port values out of native structure
As correctly mentioned in the issue, possible TCP port numbers should be in range from 0 to 65535 as per RFC.
However, if running a sample aspnetcore app with HTTP.SYS and listening on high-value port (for example 42000),
IHttpConnectionFeature
reports negative values forLocalPort
/RemotePort
(if client has high value port as well).I am proposing a fix to HttpSys.Internal SocketAddress implementation (both ipv4 and ipv6) where value coming from the native struct is basically following the IPAddress.NetworkToHostOrder() implementation. The difference is that
IPAddress.NetworkToHostOrder()
does not returnushort
and therefore does the incorrect conversion.Added tests to make sure
SocketAddressIPv4
andSocketAddressIPv6
correctly parse different values.Fixes #62128