Skip to content

Commit

Permalink
[review] More explicit size for SOCKADDR_IN
Browse files Browse the repository at this point in the history
  • Loading branch information
daladim committed Feb 25, 2021
1 parent 2f7ad00 commit 3c99013
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion heim-net/src/sys/windows/nic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use winapi::shared::minwindef::ULONG;
use winapi::shared::ntdef::NULL;
use winapi::shared::ws2def::SOCKET_ADDRESS;
use winapi::shared::ws2ipdef::SOCKADDR_IN6;
use winapi::shared::ws2def::SOCKADDR_IN;
use winapi::shared::ws2def::{AF_INET, AF_INET6};
use winapi::shared::ws2def::AF_UNSPEC;
use winapi::shared::winerror::{ERROR_BUFFER_OVERFLOW, NO_ERROR};
Expand All @@ -38,7 +39,7 @@ fn sockaddr_to_ipv4(sa: SOCKET_ADDRESS) -> Option<Address> {
// Check this sockaddr can fit one short and a char[14]
// (see https://docs.microsoft.com/en-us/windows/win32/winsock/sockaddr-2)
// This should always happen though, this is guaranteed by winapi's interface
if sa.iSockaddrLength < 2+14 {
if (sa.iSockaddrLength as usize) < std::mem::size_of::<SOCKADDR_IN>() {
return None;
}

Expand Down

0 comments on commit 3c99013

Please sign in to comment.