Commit e0c7741d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Don't use INTERNET_MAX_* macros in parse_proxy_url.

parent 72f5c3f2
...@@ -521,41 +521,32 @@ static void free_global_proxy( void ) ...@@ -521,41 +521,32 @@ static void free_global_proxy( void )
static BOOL parse_proxy_url( proxyinfo_t *info, const WCHAR *url ) static BOOL parse_proxy_url( proxyinfo_t *info, const WCHAR *url )
{ {
static const WCHAR fmt[] = {'%','s',':','%','u',0}; static const WCHAR fmt[] = {'%','.','*','s',':','%','u',0};
WCHAR hostname[INTERNET_MAX_HOST_NAME_LENGTH]; URL_COMPONENTSW uc = {sizeof(uc)};
WCHAR username[INTERNET_MAX_USER_NAME_LENGTH];
WCHAR password[INTERNET_MAX_PASSWORD_LENGTH]; uc.dwHostNameLength = 1;
URL_COMPONENTSW uc; uc.dwUserNameLength = 1;
uc.dwPasswordLength = 1;
hostname[0] = username[0] = password[0] = 0;
memset( &uc, 0, sizeof(uc) );
uc.dwStructSize = sizeof(uc);
uc.lpszHostName = hostname;
uc.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH;
uc.lpszUserName = username;
uc.dwUserNameLength = INTERNET_MAX_USER_NAME_LENGTH;
uc.lpszPassword = password;
uc.dwPasswordLength = INTERNET_MAX_PASSWORD_LENGTH;
if (!InternetCrackUrlW( url, 0, 0, &uc )) return FALSE; if (!InternetCrackUrlW( url, 0, 0, &uc )) return FALSE;
if (!hostname[0]) if (!uc.dwHostNameLength)
{ {
if (!(info->proxy = heap_strdupW( url ))) return FALSE; if (!(info->proxy = heap_strdupW( url ))) return FALSE;
info->proxyUsername = NULL; info->proxyUsername = NULL;
info->proxyPassword = NULL; info->proxyPassword = NULL;
return TRUE; return TRUE;
} }
if (!(info->proxy = heap_alloc( (strlenW(hostname) + 12) * sizeof(WCHAR) ))) return FALSE; if (!(info->proxy = heap_alloc( (uc.dwHostNameLength + 12) * sizeof(WCHAR) ))) return FALSE;
sprintfW( info->proxy, fmt, hostname, uc.nPort ); sprintfW( info->proxy, fmt, uc.dwHostNameLength, uc.lpszHostName, uc.nPort );
if (!username[0]) info->proxyUsername = NULL; if (!uc.dwUserNameLength) info->proxyUsername = NULL;
else if (!(info->proxyUsername = heap_strdupW( username ))) else if (!(info->proxyUsername = heap_strndupW( uc.lpszUserName, uc.dwUserNameLength )))
{ {
heap_free( info->proxy ); heap_free( info->proxy );
return FALSE; return FALSE;
} }
if (!password[0]) info->proxyPassword = NULL; if (!uc.dwPasswordLength) info->proxyPassword = NULL;
else if (!(info->proxyPassword = heap_strdupW( password ))) else if (!(info->proxyPassword = heap_strndupW( uc.lpszPassword, uc.dwPasswordLength )))
{ {
heap_free( info->proxyUsername ); heap_free( info->proxyUsername );
heap_free( info->proxy ); heap_free( info->proxy );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment