We shouldn't pass the struct hostent returned from gethostbyname as
it's not thread-safe and isn't needed anyway.
This commit is contained in:
parent
a63acd71c8
commit
e6157dde9d
|
@ -1656,7 +1656,6 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
|
|||
static const WCHAR szDefaultUsername[] = {'a','n','o','n','y','m','o','u','s','\0'};
|
||||
static const WCHAR szDefaultPassword[] = {'u','s','e','r','@','s','e','r','v','e','r','\0'};
|
||||
struct sockaddr_in socketAddr;
|
||||
struct hostent *phe = NULL;
|
||||
INT nsocket = -1;
|
||||
UINT sock_namelen;
|
||||
BOOL bSuccess = FALSE;
|
||||
|
@ -1734,7 +1733,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
|
|||
SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_RESOLVING_NAME,
|
||||
(LPWSTR) lpszServerName, strlenW(lpszServerName));
|
||||
|
||||
if (!GetAddress(lpszServerName, nServerPort, &phe, &socketAddr))
|
||||
if (!GetAddress(lpszServerName, nServerPort, &socketAddr))
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
|
||||
goto lerror;
|
||||
|
@ -1767,7 +1766,6 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
|
|||
|
||||
sock_namelen = sizeof(lpwfs->socketAddress);
|
||||
getsockname(nsocket, (struct sockaddr *) &lpwfs->socketAddress, &sock_namelen);
|
||||
lpwfs->phostent = phe;
|
||||
|
||||
if (FTP_ConnectToHost(lpwfs))
|
||||
{
|
||||
|
|
|
@ -813,7 +813,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
|
|||
strlenW(lpwhs->lpszServerName)+1);
|
||||
|
||||
if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
|
||||
&lpwhs->phostent, &lpwhs->socketAddress))
|
||||
&lpwhs->socketAddress))
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
|
||||
InternetCloseHandle( handle );
|
||||
|
@ -1397,7 +1397,7 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST
|
|||
strlenW(lpwhs->lpszServerName)+1);
|
||||
|
||||
if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
|
||||
&lpwhs->phostent, &lpwhs->socketAddress))
|
||||
&lpwhs->socketAddress))
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
|
||||
return FALSE;
|
||||
|
@ -1917,7 +1917,7 @@ static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr)
|
|||
&(lpwhs->socketAddress),
|
||||
sizeof(struct sockaddr_in));
|
||||
|
||||
if (!NETCON_create(&lpwhr->netConnection, lpwhs->phostent->h_addrtype,
|
||||
if (!NETCON_create(&lpwhr->netConnection, lpwhs->socketAddress.sin_family,
|
||||
SOCK_STREAM, 0))
|
||||
{
|
||||
WARN("Socket creation failed\n");
|
||||
|
|
|
@ -168,7 +168,6 @@ typedef struct
|
|||
LPWSTR lpszUserName;
|
||||
INTERNET_PORT nServerPort;
|
||||
struct sockaddr_in socketAddress;
|
||||
struct hostent *phostent;
|
||||
} WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
|
||||
|
||||
#define HDR_ISREQUEST 0x0001
|
||||
|
@ -214,7 +213,6 @@ typedef struct
|
|||
LPWININETFILE download_in_progress;
|
||||
struct sockaddr_in socketAddress;
|
||||
struct sockaddr_in lstnSocketAddress;
|
||||
struct hostent *phostent;
|
||||
LPWSTR lpszPassword;
|
||||
LPWSTR lpszUserName;
|
||||
} WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
|
||||
|
@ -420,7 +418,7 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
|
|||
DWORD dwInternalFlags);
|
||||
|
||||
BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
|
||||
struct hostent **phe, struct sockaddr_in *psa);
|
||||
struct sockaddr_in *psa);
|
||||
|
||||
void INTERNET_SetLastError(DWORD dwError);
|
||||
DWORD INTERNET_GetLastError(void);
|
||||
|
|
|
@ -127,11 +127,12 @@ time_t ConvertTimeString(LPCWSTR asctime)
|
|||
|
||||
|
||||
BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
|
||||
struct hostent **phe, struct sockaddr_in *psa)
|
||||
struct sockaddr_in *psa)
|
||||
{
|
||||
WCHAR *found;
|
||||
char *name;
|
||||
int len, sz;
|
||||
struct hostent *phe;
|
||||
|
||||
TRACE("%s\n", debugstr_w(lpszServerName));
|
||||
|
||||
|
@ -150,18 +151,18 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
|
|||
name = HeapAlloc(GetProcessHeap(), 0, sz+1);
|
||||
WideCharToMultiByte( CP_UNIXCP, 0, lpszServerName, len, name, sz, NULL, NULL );
|
||||
name[sz] = 0;
|
||||
*phe = gethostbyname(name);
|
||||
phe = gethostbyname(name);
|
||||
HeapFree( GetProcessHeap(), 0, name );
|
||||
|
||||
if (NULL == *phe)
|
||||
if (NULL == phe)
|
||||
{
|
||||
TRACE("Failed to get hostname: (%s)\n", debugstr_w(lpszServerName) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memset(psa,0,sizeof(struct sockaddr_in));
|
||||
memcpy((char *)&psa->sin_addr, (*phe)->h_addr, (*phe)->h_length);
|
||||
psa->sin_family = (*phe)->h_addrtype;
|
||||
memcpy((char *)&psa->sin_addr, phe->h_addr, phe->h_length);
|
||||
psa->sin_family = phe->h_addrtype;
|
||||
psa->sin_port = htons((u_short)nServerPort);
|
||||
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in New Issue