[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: WININET: lpvStatusInfo in INTERNET_STATUS_NAME_RESOLVED,
From:       Robert Shearman <rob () codeweavers ! com>
Date:       2005-12-31 17:06:57
Message-ID: 43B6BAB1.7020002 () codeweavers ! com
[Download RAW message or body]

Jacek Caban wrote:

>+    /* FIXME: inet_ntoa is not thread safe. */
>+    szaddr = WININET_strdup_AtoW(inet_ntoa(lpwhs->socketAddress.sin_addr));
>     INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
>                           INTERNET_STATUS_NAME_RESOLVED,
>-                          &(lpwhs->socketAddress),
>-                          sizeof(struct sockaddr_in));
>+                          szaddr, strlenW(szaddr));
>+    HeapFree(GetProcessHeap(), 0, szaddr);
>  
>

Like the comment says, it is not thread-safe. I don't think it is wise 
to delibrately introduce race conditions like this and it tends to cause 
problems with applications that rely heavily on multiple threads (such 
as iTunes). It would be better to use the thread-safe inet_ntop (which 
also has the bonus of supporting IPv6) or the ws2_32 version of inet_ntoa.

-- 
Rob Shearman



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic