Commit e0e9195c authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

secur32: Improve error handling for gnutls_global_init().

parent 60435135
...@@ -538,8 +538,30 @@ static const WCHAR schannelDllName[] = { 's','c','h','a','n','n','e','l','.','d' ...@@ -538,8 +538,30 @@ static const WCHAR schannelDllName[] = { 's','c','h','a','n','n','e','l','.','d'
void SECUR32_initSchannelSP(void) void SECUR32_initSchannelSP(void)
{ {
/* This is what Windows reports. This shouldn't break any applications
* even though the functions are missing, because the wrapper will
* return SEC_E_UNSUPPORTED_FUNCTION if our function is NULL.
*/
static const long caps =
SECPKG_FLAG_INTEGRITY |
SECPKG_FLAG_PRIVACY |
SECPKG_FLAG_CONNECTION |
SECPKG_FLAG_MULTI_REQUIRED |
SECPKG_FLAG_EXTENDED_ERROR |
SECPKG_FLAG_IMPERSONATION |
SECPKG_FLAG_ACCEPT_WIN32_NAME |
SECPKG_FLAG_STREAM;
static const short version = 1;
static const long maxToken = 16384;
SEC_WCHAR *uniSPName = (SEC_WCHAR *)UNISP_NAME_W,
*schannel = (SEC_WCHAR *)SCHANNEL_NAME_W;
const SecPkgInfoW info[] = {
{ caps, version, UNISP_RPC_ID, maxToken, uniSPName, uniSPName },
{ caps, version, UNISP_RPC_ID, maxToken, schannel,
(SEC_WCHAR *)schannelComment },
};
SecureProvider *provider; SecureProvider *provider;
int ret;
libgnutls_handle = wine_dlopen(SONAME_LIBGNUTLS, RTLD_NOW, NULL, 0); libgnutls_handle = wine_dlopen(SONAME_LIBGNUTLS, RTLD_NOW, NULL, 0);
if (!libgnutls_handle) if (!libgnutls_handle)
...@@ -552,9 +574,7 @@ void SECUR32_initSchannelSP(void) ...@@ -552,9 +574,7 @@ void SECUR32_initSchannelSP(void)
if (!(p##f = wine_dlsym(libgnutls_handle, #f, NULL, 0))) \ if (!(p##f = wine_dlsym(libgnutls_handle, #f, NULL, 0))) \
{ \ { \
ERR("Failed to load %s\n", #f); \ ERR("Failed to load %s\n", #f); \
wine_dlclose(libgnutls_handle, NULL, 0); \ goto fail; \
libgnutls_handle = NULL; \
return; \
} }
LOAD_FUNCPTR(gnutls_certificate_allocate_credentials) LOAD_FUNCPTR(gnutls_certificate_allocate_credentials)
...@@ -566,53 +586,52 @@ void SECUR32_initSchannelSP(void) ...@@ -566,53 +586,52 @@ void SECUR32_initSchannelSP(void)
LOAD_FUNCPTR(gnutls_perror) LOAD_FUNCPTR(gnutls_perror)
#undef LOAD_FUNCPTR #undef LOAD_FUNCPTR
provider = SECUR32_addProvider(&schanTableA, &schanTableW, schannelDllName); ret = pgnutls_global_init();
if (ret != GNUTLS_E_SUCCESS)
{
pgnutls_perror(ret);
goto fail;
}
if (provider) if (TRACE_ON(secur32))
{ {
/* This is what Windows reports. This shouldn't break any applications pgnutls_global_set_log_level(4);
* even though the functions are missing, because the wrapper will pgnutls_global_set_log_function(schan_gnutls_log);
* return SEC_E_UNSUPPORTED_FUNCTION if our function is NULL. }
*/
static const long caps = schan_handle_table = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 64 * sizeof(*schan_handle_table));
SECPKG_FLAG_INTEGRITY | if (!schan_handle_table)
SECPKG_FLAG_PRIVACY | {
SECPKG_FLAG_CONNECTION | ERR("Failed to allocate schannel handle table.\n");
SECPKG_FLAG_MULTI_REQUIRED | goto fail;
SECPKG_FLAG_EXTENDED_ERROR |
SECPKG_FLAG_IMPERSONATION |
SECPKG_FLAG_ACCEPT_WIN32_NAME |
SECPKG_FLAG_STREAM;
static const short version = 1;
static const long maxToken = 16384;
SEC_WCHAR *uniSPName = (SEC_WCHAR *)UNISP_NAME_W,
*schannel = (SEC_WCHAR *)SCHANNEL_NAME_W;
const SecPkgInfoW info[] = {
{ caps, version, UNISP_RPC_ID, maxToken, uniSPName, uniSPName },
{ caps, version, UNISP_RPC_ID, maxToken, schannel,
(SEC_WCHAR *)schannelComment },
};
SECUR32_addPackages(provider, sizeof(info) / sizeof(info[0]), NULL,
info);
schan_handle_table = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 64 * sizeof(*schan_handle_table));
schan_handle_table_size = 64;
pgnutls_global_init();
if (TRACE_ON(secur32))
{
pgnutls_global_set_log_level(4);
pgnutls_global_set_log_function(schan_gnutls_log);
}
} }
schan_handle_table_size = 64;
provider = SECUR32_addProvider(&schanTableA, &schanTableW, schannelDllName);
if (!provider)
{
ERR("Failed to add schannel provider.\n");
goto fail;
}
SECUR32_addPackages(provider, sizeof(info) / sizeof(info[0]), NULL, info);
return;
fail:
HeapFree(GetProcessHeap(), 0, schan_handle_table);
schan_handle_table = NULL;
wine_dlclose(libgnutls_handle, NULL, 0);
libgnutls_handle = NULL;
return;
} }
void SECUR32_deinitSchannelSP(void) void SECUR32_deinitSchannelSP(void)
{ {
if (!libgnutls_handle) return;
pgnutls_global_deinit(); pgnutls_global_deinit();
if (libgnutls_handle) wine_dlclose(libgnutls_handle, NULL, 0); wine_dlclose(libgnutls_handle, NULL, 0);
} }
#else /* SONAME_LIBGNUTLS */ #else /* SONAME_LIBGNUTLS */
......
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