wininet: Don't use INTERNET_MAX_HOST_NAME_LENGTH in InternetCheckConnectionW.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e0c7741d22
commit
8e2586db52
|
@ -3330,13 +3330,12 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
|
||||||
BOOL rc = FALSE;
|
BOOL rc = FALSE;
|
||||||
static const CHAR ping[] = "ping -c 1 ";
|
static const CHAR ping[] = "ping -c 1 ";
|
||||||
static const CHAR redirect[] = " >/dev/null 2>/dev/null";
|
static const CHAR redirect[] = " >/dev/null 2>/dev/null";
|
||||||
CHAR *command = NULL;
|
WCHAR *host;
|
||||||
WCHAR hostW[INTERNET_MAX_HOST_NAME_LENGTH];
|
DWORD len, host_len;
|
||||||
DWORD len;
|
|
||||||
INTERNET_PORT port;
|
INTERNET_PORT port;
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
|
||||||
FIXME("\n");
|
FIXME("(%s %x %x)\n", debugstr_w(lpszUrl), dwFlags, dwReserved);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Crack or set the Address
|
* Crack or set the Address
|
||||||
|
@ -3355,27 +3354,34 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
URL_COMPONENTSW components;
|
URL_COMPONENTSW components = {sizeof(components)};
|
||||||
|
|
||||||
ZeroMemory(&components,sizeof(URL_COMPONENTSW));
|
components.dwHostNameLength = 1;
|
||||||
components.lpszHostName = (LPWSTR)hostW;
|
|
||||||
components.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH;
|
|
||||||
|
|
||||||
if (!InternetCrackUrlW(lpszUrl,0,0,&components))
|
if (!InternetCrackUrlW(lpszUrl,0,0,&components))
|
||||||
goto End;
|
goto End;
|
||||||
|
|
||||||
TRACE("host name : %s\n",debugstr_w(components.lpszHostName));
|
host = components.lpszHostName;
|
||||||
|
host_len = components.dwHostNameLength;
|
||||||
port = components.nPort;
|
port = components.nPort;
|
||||||
TRACE("port: %d\n", port);
|
TRACE("host name: %s port: %d\n",debugstr_wn(host, host_len), port);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dwFlags & FLAG_ICC_FORCE_CONNECTION)
|
if (dwFlags & FLAG_ICC_FORCE_CONNECTION)
|
||||||
{
|
{
|
||||||
struct sockaddr_storage saddr;
|
struct sockaddr_storage saddr;
|
||||||
socklen_t sa_len = sizeof(saddr);
|
socklen_t sa_len = sizeof(saddr);
|
||||||
|
WCHAR *host_z;
|
||||||
int fd;
|
int fd;
|
||||||
|
BOOL b;
|
||||||
|
|
||||||
if (!GetAddress(hostW, port, (struct sockaddr *)&saddr, &sa_len, NULL))
|
host_z = heap_strndupW(host, host_len);
|
||||||
|
if (!host_z)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
b = GetAddress(host_z, port, (struct sockaddr *)&saddr, &sa_len, NULL);
|
||||||
|
heap_free(host_z);
|
||||||
|
if(!b)
|
||||||
goto End;
|
goto End;
|
||||||
init_winsock();
|
init_winsock();
|
||||||
fd = socket(saddr.ss_family, SOCK_STREAM, 0);
|
fd = socket(saddr.ss_family, SOCK_STREAM, 0);
|
||||||
|
@ -3391,15 +3397,18 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
|
||||||
/*
|
/*
|
||||||
* Build our ping command
|
* Build our ping command
|
||||||
*/
|
*/
|
||||||
len = WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, NULL, 0, NULL, NULL);
|
char *command;
|
||||||
command = heap_alloc(strlen(ping)+len+strlen(redirect));
|
|
||||||
strcpy(command,ping);
|
len = WideCharToMultiByte(CP_UNIXCP, 0, host, host_len, NULL, 0, NULL, NULL);
|
||||||
WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, command+strlen(ping), len, NULL, NULL);
|
command = heap_alloc(strlen(ping)+len+strlen(redirect)+1);
|
||||||
strcat(command,redirect);
|
strcpy(command, ping);
|
||||||
|
WideCharToMultiByte(CP_UNIXCP, 0, host, host_len, command+sizeof(ping)-1, len, NULL, NULL);
|
||||||
|
strcpy(command+sizeof(ping)-1+len, redirect);
|
||||||
|
|
||||||
TRACE("Ping command is : %s\n",command);
|
TRACE("Ping command is : %s\n",command);
|
||||||
|
|
||||||
status = system(command);
|
status = system(command);
|
||||||
|
heap_free( command );
|
||||||
|
|
||||||
TRACE("Ping returned a code of %i\n",status);
|
TRACE("Ping returned a code of %i\n",status);
|
||||||
|
|
||||||
|
@ -3409,7 +3418,6 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
|
||||||
}
|
}
|
||||||
|
|
||||||
End:
|
End:
|
||||||
heap_free( command );
|
|
||||||
if (rc == FALSE)
|
if (rc == FALSE)
|
||||||
INTERNET_SetLastError(ERROR_NOT_CONNECTED);
|
INTERNET_SetLastError(ERROR_NOT_CONNECTED);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue