Skip to content

Commit

Permalink
Fix endianness issue with incoming IPv6 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshia001 authored and theduke committed Sep 6, 2023
1 parent 94f27f8 commit 42596c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions lib/wasix/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,9 @@ pub(crate) fn read_ip_port<M: MemorySize>(
(IpAddr::V4(Ipv4Addr::new(o[2], o[3], o[4], o[5])), port)
}
Addressfamily::Inet6 => {
let [a, b, c, d, e, f, g, h] = {
let o = [
o[2], o[3], o[4], o[5], o[6], o[7], o[8], o[9], o[10], o[11], o[12], o[13],
o[14], o[15], o[16], o[17],
];
unsafe { transmute::<_, [u16; 8]>(o) }
};
let octets: [u8; 16] = o[2..18].try_into().unwrap();
(
IpAddr::V6(Ipv6Addr::new(a, b, c, d, e, f, g, h)),
IpAddr::V6(Ipv6Addr::from(octets)),
u16::from_ne_bytes([o[0], o[1]]),
)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/wasix/src/net/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl InodeSocket {

match *ty {
Socktype::Stream => {
// we already set the socket address - next we need a bind or connect so nothing
// we already set the socket address - next we need a listen or connect so nothing
// more to do at this time
return Ok(None);
}
Expand Down

0 comments on commit 42596c2

Please sign in to comment.