ws2_32: Don't overwrite address length before checking it.

This commit is contained in:
Juan Lang 2009-10-16 16:53:53 -07:00 committed by Alexandre Julliard
parent f8bd01a315
commit d1963ee2f1
1 changed files with 4 additions and 1 deletions

View File

@ -1219,13 +1219,16 @@ static int ws_sockaddr_u2ws(const struct sockaddr* uaddr, struct WS_sockaddr* ws
win6old->sin6_port = uin6->sin6_port;
win6old->sin6_flowinfo = uin6->sin6_flowinfo;
memcpy(&win6old->sin6_addr,&uin6->sin6_addr,16); /* 16 bytes = 128 address bits */
*wsaddrlen = sizeof(struct WS_sockaddr_in6_old);
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
if (*wsaddrlen >= sizeof(struct WS_sockaddr_in6)) {
struct WS_sockaddr_in6* win6 = (struct WS_sockaddr_in6*)wsaddr;
win6->sin6_scope_id = uin6->sin6_scope_id;
*wsaddrlen = sizeof(struct WS_sockaddr_in6);
}
else
*wsaddrlen = sizeof(struct WS_sockaddr_in6_old);
#else
*wsaddrlen = sizeof(struct WS_sockaddr_in6_old);
#endif
return 0;
}