Check return value from SSL_new

This commit is contained in:
Ian Craggs 2026-02-13 15:42:53 +00:00
parent 447fddcad8
commit 9f76932acf
No known key found for this signature in database
GPG Key ID: A7AE1A8F2CCAB186
1 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2023 IBM Corp., Ian Craggs
* Copyright (c) 2009, 2026 IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
@ -724,7 +724,14 @@ int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts,
if (opts->enableServerCertAuth)
SSL_CTX_set_verify(net->ctx, SSL_VERIFY_PEER, NULL);
net->ssl = SSL_new(net->ctx);
if ((net->ssl = SSL_new(net->ctx)) == NULL)
{
if (opts->struct_version >= 3)
rc = SSLSocket_error("SSL_new", net->ssl, net->socket, rc, opts->ssl_error_cb, opts->ssl_error_context);
else
rc = SSLSocket_error("SSL_new", net->ssl, net->socket, rc, NULL, NULL);
goto exit;
}
/* Log all ciphers available to the SSL sessions (loaded in ctx) */
for (i = 0; ;i++)
@ -755,7 +762,7 @@ int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts,
else
rc = PAHO_MEMORY_ERROR;
}
exit:
FUNC_EXIT_RC(rc);
return rc;
}