Skip to content

Commit

Permalink
Merge pull request SoftEtherVPN#2036 from icy17/null-check3
Browse files Browse the repository at this point in the history
Fix potential NULL pointer dereference
  • Loading branch information
chipitsine authored Aug 14, 2024
2 parents a8ce56b + e201777 commit 31fed5a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Mayaqua/Encrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ MD *NewMdEx(char *name, bool hmac)
#else
m->Ctx = EVP_MD_CTX_create();
#endif
if (m->Ctx == NULL)
{
return NULL;
}

if (EVP_DigestInit_ex(m->Ctx, m->Md, NULL) == false)
{
Debug("NewMdEx(): EVP_DigestInit_ex() failed with error: %s\n", OpenSSL_Error());
Expand Down Expand Up @@ -4604,6 +4609,11 @@ DH_CTX *DhNew(char *prime, UINT g)
dh = ZeroMalloc(sizeof(DH_CTX));

dh->dh = DH_new();
if (dh->dh == NULL)
{
return NULL;
}

#if OPENSSL_VERSION_NUMBER >= 0x10100000L
dhp = BinToBigNum(buf->Buf, buf->Size);
dhg = BN_new();
Expand Down
12 changes: 12 additions & 0 deletions src/Mayaqua/Network.c
Original file line number Diff line number Diff line change
Expand Up @@ -11860,6 +11860,12 @@ bool StartSSLEx3(SOCK *sock, X *x, K *priv, LIST *chain, UINT ssl_timeout, char
#endif

sock->ssl = SSL_new(ssl_ctx);

if (sock->ssl == NULL)
{
return false;
}

SSL_set_fd(sock->ssl, (int)sock->socket);

#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
Expand Down Expand Up @@ -16250,6 +16256,12 @@ UINT GetOSSecurityLevel()
UINT security_level_new = 0, security_level_set_ssl_version = 0;
struct ssl_ctx_st *ctx = SSL_CTX_new(SSLv23_method());

if (ctx == NULL)
{
return security_level_new;
}


#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
security_level_new = SSL_CTX_get_security_level(ctx);
#endif
Expand Down

0 comments on commit 31fed5a

Please sign in to comment.