Skip to content

Commit 1d06278

Browse files
author
RoomWithOutRoof
committed
crypto: add NULL check for SSL_new() result in SSLPointer::New
Add explicit NULL check for SSL_new() return value in SSLPointer::New(), consistent with the pattern used by CipherCtxPointer::New(). Fixes a potential NULL pointer dereference when OpenSSL fails to allocate an SSL structure under memory pressure (Coverity CID 15826735). Fixes: #62774
1 parent d0fa608 commit 1d06278

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

deps/ncrypto/ncrypto.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2828,7 +2828,9 @@ SSL* SSLPointer::release() {
28282828

28292829
SSLPointer SSLPointer::New(const SSLCtxPointer& ctx) {
28302830
if (!ctx) return {};
2831-
return SSLPointer(SSL_new(ctx.get()));
2831+
SSL* ssl = SSL_new(ctx.get());
2832+
if (ssl == nullptr) return {};
2833+
return SSLPointer(ssl);
28322834
}
28332835

28342836
void SSLPointer::getCiphers(std::function<void(const char*)> cb) const {

0 commit comments

Comments
 (0)