Module: wine Branch: refs/heads/master Commit: 9981f337e3aa38cc1b1cbf89f646030397540cd8 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=9981f337e3aa38cc1b1cbf89...
Author: Robert Shearman rob@codeweavers.com Date: Mon Mar 6 17:31:09 2006 +0000
wininet: Don't continue to connect to a secure server without SSL support since it won't work.
Don't continue to connect to a secure server without SSL support since it won't work. Return an error back to the application instead.
---
dlls/wininet/http.c | 11 +++++++++-- dlls/wininet/internet.h | 2 +- dlls/wininet/netconnection.c | 31 ++++++++++++++++++------------- 3 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 9e74001..495b0b5 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -1016,7 +1016,12 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(L goto lend; }
- NETCON_init(&lpwhr->netConnection, dwFlags & INTERNET_FLAG_SECURE); + if (!NETCON_init(&lpwhr->netConnection, dwFlags & INTERNET_FLAG_SECURE)) + { + InternetCloseHandle( handle ); + handle = NULL; + goto lend; + }
if (NULL != lpszObjectName && strlenW(lpszObjectName)) { HRESULT rc; @@ -2077,7 +2082,9 @@ static BOOL HTTP_HandleRedirect(LPWININE szaddr, strlen(szaddr)+1);
NETCON_close(&lpwhr->netConnection); - NETCON_init(&lpwhr->netConnection,lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE); + + if (!NETCON_init(&lpwhr->netConnection,lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE)) + return FALSE; }
HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath); diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index 6df7e31..6399de9 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -468,7 +468,7 @@ VOID INTERNET_SendCallback(LPWININETHAND LPHTTPHEADERW HTTP_GetHeader(LPWININETHTTPREQW lpwhr, LPCWSTR header);
BOOL NETCON_connected(WININET_NETCONNECTION *connection); -void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL); +BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL); BOOL NETCON_create(WININET_NETCONNECTION *connection, int domain, int type, int protocol); BOOL NETCON_close(WININET_NETCONNECTION *connection); diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c index 97608b6..e046e04 100644 --- a/dlls/wininet/netconnection.c +++ b/dlls/wininet/netconnection.c @@ -111,7 +111,7 @@ MAKE_FUNCPTR(ERR_error_string);
#endif
-void NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL) +BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL) { connection->useSSL = FALSE; connection->socketFD = -1; @@ -119,23 +119,23 @@ void NETCON_init(WININET_NETCONNECTION * { #if defined HAVE_OPENSSL_SSL_H && defined HAVE_OPENSSL_ERR_H TRACE("using SSL connection\n"); - if (OpenSSL_ssl_handle) /* already initilzed everything */ - return; + if (OpenSSL_ssl_handle) /* already initialized everything */ + return TRUE; OpenSSL_ssl_handle = wine_dlopen(SONAME_LIBSSL, RTLD_NOW, NULL, 0); if (!OpenSSL_ssl_handle) { ERR("trying to use a SSL connection, but couldn't load %s. Expect trouble.\n", SONAME_LIBSSL); - connection->useSSL = FALSE; - return; + INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); + return FALSE; } OpenSSL_crypto_handle = wine_dlopen(SONAME_LIBCRYPTO, RTLD_NOW, NULL, 0); if (!OpenSSL_crypto_handle) { ERR("trying to use a SSL connection, but couldn't load %s. Expect trouble.\n", SONAME_LIBCRYPTO); - connection->useSSL = FALSE; - return; + INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); + return FALSE; }
/* mmm nice ugly macroness */ @@ -144,8 +144,8 @@ void NETCON_init(WININET_NETCONNECTION * if (!p##x) \ { \ ERR("failed to load symbol %s\n", #x); \ - connection->useSSL = FALSE; \ - return; \ + INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); \ + return FALSE; \ }
DYNSSL(SSL_library_init); @@ -172,8 +172,8 @@ void NETCON_init(WININET_NETCONNECTION * if (!p##x) \ { \ ERR("failed to load symbol %s\n", #x); \ - connection->useSSL = FALSE; \ - return; \ + INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); \ + return FALSE; \ } DYNCRYPTO(BIO_new_fp); DYNCRYPTO(ERR_get_error); @@ -189,9 +189,11 @@ void NETCON_init(WININET_NETCONNECTION * connection->peek_msg_mem = NULL; #else FIXME("can't use SSL, not compiled in.\n"); - connection->useSSL = FALSE; + INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); + return FALSE; #endif } + return TRUE; }
BOOL NETCON_connected(WININET_NETCONNECTION *connection) @@ -353,6 +355,7 @@ BOOL NETCON_secure_connect(WININET_NETCO { ERR("SSL_CTX_set_default_verify_paths failed: %s\n", pERR_error_string(pERR_get_error(), 0)); + INTERNET_SetLastError(ERROR_OUTOFMEMORY); return FALSE; } connection->ssl_s = pSSL_new(ctx); @@ -360,6 +363,7 @@ BOOL NETCON_secure_connect(WININET_NETCO { ERR("SSL_new failed: %s\n", pERR_error_string(pERR_get_error(), 0)); + INTERNET_SetLastError(ERROR_OUTOFMEMORY); goto fail; }
@@ -367,6 +371,7 @@ BOOL NETCON_secure_connect(WININET_NETCO { ERR("SSL_set_fd failed: %s\n", pERR_error_string(pERR_get_error(), 0)); + INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); goto fail; }
@@ -397,7 +402,7 @@ BOOL NETCON_secure_connect(WININET_NETCO hostname_unix = HeapAlloc(GetProcessHeap(), 0, len); if (!hostname_unix) { - INTERNET_SetLastError(ERROR_NOT_ENOUGH_MEMORY); + INTERNET_SetLastError(ERROR_OUTOFMEMORY); goto fail; } WideCharToMultiByte(CP_UNIXCP, 0, hostname, -1, hostname_unix, len, NULL, NULL);