ws2_32: ws_sockaddr_u2ws should zero the WS_sockaddr before using it.

Kai Blin kai.blin at gmail.com
Wed Dec 20 06:59:03 CST 2006


On Wednesday 20 December 2006 13:37, Francois Gouget wrote:
> On Wed, 20 Dec 2006, Kai Blin wrote:
>
> @@ -946,6 +946,9 @@ static int ws_sockaddr_u2ws(const struct
>  {
>      int res;
>
> +    /* Zero the ws_sockaddr structure before using */
> +    memset(wsaddr, 0, *wsaddrlen);
>
> Are you sure this is needed in ws_sockaddr_u2ws() or should it rather be
> done by getsockname() (as your test indicates).

Well, this seemed the best place to do this, as it basically contains the 
getsockname() logic. 

> Also, do we know of a 
> real-world application that needs this?

I don't know of any real world applications that need this, but it sure is 
making my life easier when trying to figure out directplay traces. Native 
dplay seems to use getsockname() to construct the dplay headers.

> Finally, this memset() makes the one in the AF_UNSPEC case redundant,
> and may itself be redundant with some of the memcpy()s...

True. I'll adapt the patch to do the memset only in the AF_INET case, and only 
set the sin_zero member to 0.

Cheers,
Kai

-- 
Kai Blin, <kai Dot blin At gmail Dot com>
WorldForge developer    http://www.worldforge.org/
Wine developer          http://wiki.winehq.org/KaiBlin/
--
Will code for cotton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20061220/9e65468e/attachment.pgp


More information about the wine-devel mailing list