Fix byte-swapped flowinfo and scope_id #1969
Closed
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.
The
From<SockaddrIn6> for net::SocketAddrV6
implementation usedfrom_be()
on each of the port/flowinfo/scope_id fields, but the flowinfo and scope_id are not stored in big endian, causing the conversion to produce aSocketAddrV6
with byte-swapped flowinfo and scope_id. I noticed this when runninggetifaddrs()
on my machine and then converting to a standardSocketAddrV6
created an address with a scope ID of33554432
(hex0x02000000
) for an interface that should have been scope id 2.I added a basic test to round-trip between a standard
SocketAddrV6
and aSockaddrIn6
; prior to the change to theFrom
impl, this test failed withwhere
67305985 == 0x4030201
is the byte-swapped value of16909060 == 0x1020304
, the expected value.