From: Marc-Aurel Zent marc_aurel@me.com
Interpreting the fist two bytes of the sockaddr struct as sa_family produces incorrect behaviour on macOS and (presumbly) BSD. This change is however still backwards compatible with Linux since sa_family_t is uint8_t and sa_len is currently disregarded. --- dlls/wpcap/unixlib.h | 3 ++- dlls/wpcap/wpcap.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/wpcap/unixlib.h b/dlls/wpcap/unixlib.h index 8cd64ef0210..41a7fa7568f 100644 --- a/dlls/wpcap/unixlib.h +++ b/dlls/wpcap/unixlib.h @@ -19,7 +19,8 @@
struct sockaddr_hdr { - unsigned short sa_family; + unsigned char sa_len; + unsigned char sa_family; };
struct pcap_address diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c index df35954bfa7..6a2c8e18f82 100644 --- a/dlls/wpcap/wpcap.c +++ b/dlls/wpcap/wpcap.c @@ -248,7 +248,7 @@ static struct sockaddr_hdr *dup_sockaddr( const struct sockaddr_hdr *addr ) { struct sockaddr_in *dst, *src = (struct sockaddr_in *)addr; if (!(dst = calloc( 1, sizeof(*dst) ))) return NULL; - dst->sin_family = src->sin_family; + dst->sin_family = AF_INET; dst->sin_port = src->sin_port; dst->sin_addr = src->sin_addr; ret = (struct sockaddr_hdr *)dst; @@ -258,7 +258,7 @@ static struct sockaddr_hdr *dup_sockaddr( const struct sockaddr_hdr *addr ) { struct sockaddr_in6 *dst, *src = (struct sockaddr_in6 *)addr; if (!(dst = malloc( sizeof(*dst) ))) return NULL; - dst->sin6_family = src->sin6_family; + dst->sin6_family = AF_INET6; dst->sin6_port = src->sin6_port; dst->sin6_flowinfo = src->sin6_flowinfo; dst->sin6_addr = src->sin6_addr;