diff --git a/libfreerdp/common/assistance.c b/libfreerdp/common/assistance.c index 97770b8f1..212e8467b 100644 --- a/libfreerdp/common/assistance.c +++ b/libfreerdp/common/assistance.c @@ -1397,7 +1397,9 @@ static BOOL setup_string(wArrayList* list) rdpAssistanceFile* freerdp_assistance_file_new(void) { - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + return nullptr; + rdpAssistanceFile* file = calloc(1, sizeof(rdpAssistanceFile)); if (!file) return nullptr; diff --git a/libfreerdp/common/test/TestCommonAssistance.c b/libfreerdp/common/test/TestCommonAssistance.c index 4a6ce2557..f62faa9f6 100644 --- a/libfreerdp/common/test/TestCommonAssistance.c +++ b/libfreerdp/common/test/TestCommonAssistance.c @@ -286,11 +286,11 @@ static BOOL test_msrsc_incident_file_type2(wLog* log) int TestCommonAssistance(int argc, char* argv[]) { - wLog* log = nullptr; WINPR_UNUSED(argc); WINPR_UNUSED(argv); - log = WLog_Get(__func__); - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + wLog* log = WLog_Get(__func__); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + return -1; for (size_t x = 0; x < ARRAYSIZE(fail_tests); x++) { diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index daafec5c6..569f7640a 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -1479,7 +1479,9 @@ int main(int argc, char* argv[]) } WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi()); - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + return -1; + instance = freerdp_listener_new(); if (!instance) diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 4d645d1ec..db0e2e5df 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -813,7 +813,8 @@ BOOL pf_server_start(proxyServer* server) WINPR_ASSERT(server); WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi()); - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + goto error; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) goto error; @@ -853,7 +854,8 @@ BOOL pf_server_start_from_socket(proxyServer* server, int socket) WINPR_ASSERT(server); WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi()); - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + goto error; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) goto error; diff --git a/winpr/libwinpr/crypto/test/TestCryptoCipher.c b/winpr/libwinpr/crypto/test/TestCryptoCipher.c index 200df7885..bd6548f06 100644 --- a/winpr/libwinpr/crypto/test/TestCryptoCipher.c +++ b/winpr/libwinpr/crypto/test/TestCryptoCipher.c @@ -233,7 +233,8 @@ int TestCryptoCipher(int argc, char* argv[]) WINPR_UNUSED(argc); WINPR_UNUSED(argv); - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + return -1; if (!test_crypto_cipher_aes_128_cbc(TRUE)) return -1; diff --git a/winpr/libwinpr/crypto/test/TestCryptoHash.c b/winpr/libwinpr/crypto/test/TestCryptoHash.c index a1aea53fa..b6a4c653f 100644 --- a/winpr/libwinpr/crypto/test/TestCryptoHash.c +++ b/winpr/libwinpr/crypto/test/TestCryptoHash.c @@ -297,7 +297,8 @@ int TestCryptoHash(int argc, char* argv[]) WINPR_UNUSED(argc); WINPR_UNUSED(argv); - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + return -1; if (!test_crypto_hash_md5()) return -1; diff --git a/winpr/libwinpr/crypto/test/TestCryptoProtectMemory.c b/winpr/libwinpr/crypto/test/TestCryptoProtectMemory.c index 828dfb346..1a8da0734 100644 --- a/winpr/libwinpr/crypto/test/TestCryptoProtectMemory.c +++ b/winpr/libwinpr/crypto/test/TestCryptoProtectMemory.c @@ -9,6 +9,7 @@ static const char* SECRET_PASSWORD_TEST = "MySecretPassword123!"; int TestCryptoProtectMemory(int argc, char* argv[]) { + int rc = -1; UINT32 cbPlainText = 0; UINT32 cbCipherText = 0; const char* pPlainText = nullptr; @@ -30,12 +31,13 @@ int TestCryptoProtectMemory(int argc, char* argv[]) } CopyMemory(pCipherText, pPlainText, cbPlainText); ZeroMemory(&pCipherText[cbPlainText], (cbCipherText - cbPlainText)); - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + goto fail; if (!CryptProtectMemory(pCipherText, cbCipherText, CRYPTPROTECTMEMORY_SAME_PROCESS)) { printf("CryptProtectMemory failure\n"); - return -1; + goto fail; } printf("PlainText: %s (cbPlainText = %" PRIu32 ", cbCipherText = %" PRIu32 ")\n", pPlainText, @@ -45,11 +47,14 @@ int TestCryptoProtectMemory(int argc, char* argv[]) if (!CryptUnprotectMemory(pCipherText, cbCipherText, CRYPTPROTECTMEMORY_SAME_PROCESS)) { printf("CryptUnprotectMemory failure\n"); - return -1; + goto fail; } printf("Decrypted CipherText: %s\n", pCipherText); SecureZeroMemory(pCipherText, cbCipherText); + + rc = 0; +fail: free(pCipherText); - return 0; + return rc; } diff --git a/winpr/libwinpr/sspi/Schannel/schannel_openssl.c b/winpr/libwinpr/sspi/Schannel/schannel_openssl.c index 231238ff1..bcec783cf 100644 --- a/winpr/libwinpr/sspi/Schannel/schannel_openssl.c +++ b/winpr/libwinpr/sspi/Schannel/schannel_openssl.c @@ -587,12 +587,13 @@ SECURITY_STATUS schannel_openssl_decrypt_message(SCHANNEL_OPENSSL* context, PSec SCHANNEL_OPENSSL* schannel_openssl_new(void) { - SCHANNEL_OPENSSL* context = nullptr; - context = (SCHANNEL_OPENSSL*)calloc(1, sizeof(SCHANNEL_OPENSSL)); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + return nullptr; + + SCHANNEL_OPENSSL* context = (SCHANNEL_OPENSSL*)calloc(1, sizeof(SCHANNEL_OPENSSL)); if (context != nullptr) { - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); context->connected = FALSE; } diff --git a/winpr/libwinpr/sspi/sspi_winpr.c b/winpr/libwinpr/sspi/sspi_winpr.c index bfe2c606c..3a308b0ef 100644 --- a/winpr/libwinpr/sspi/sspi_winpr.c +++ b/winpr/libwinpr/sspi/sspi_winpr.c @@ -972,7 +972,8 @@ static BOOL WINPR_init(void) static BOOL CALLBACK sspi_init(WINPR_ATTR_UNUSED PINIT_ONCE InitOnce, WINPR_ATTR_UNUSED PVOID Parameter, WINPR_ATTR_UNUSED PVOID* Context) { - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + return FALSE; sspi_ContextBufferAllocTableNew(); if (!SCHANNEL_init()) return FALSE; diff --git a/winpr/tools/hash-cli/hash.c b/winpr/tools/hash-cli/hash.c index c6223726b..78d9e132b 100644 --- a/winpr/tools/hash-cli/hash.c +++ b/winpr/tools/hash-cli/hash.c @@ -153,7 +153,11 @@ int main(int argc, char* argv[]) printf("missing username or password\n\n"); return usage_and_exit(); } - winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT); + if (!winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT)) + { + printf("winpr_InitializeSSL failed\n\n"); + return usage_and_exit(); + } UserLength = strlen(User); PasswordLength = strlen(Password);