Skip to content

Commit

Permalink
Bug#35715333 SSL_get_error must be called in same critical section as…
Browse files Browse the repository at this point in the history
… SSL_read/peek_ex

Move call to SSL_get_error into same critical sections as potentially
failing call to SSL_read_ex and SSL_peek_ex in NdbSocket.

Change-Id: I6dcfbda7284e0eae6899a10967d3c1c08e2db8e2
  • Loading branch information
zmur committed Aug 22, 2023
1 parent e35f76e commit d3aea14
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions storage/ndb/src/common/util/NdbSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,14 @@ ssize_t NdbSocket::ssl_recv(char *buf, size_t len) const
{
bool r;
size_t nread = 0;
int err;
{
Guard2 guard(mutex); // acquire mutex if non-null
r = SSL_read_ex(ssl, buf, len, &nread);
if(r) return nread;
err = SSL_get_error(ssl, r);
}

if(r) return nread;
int err = SSL_get_error(ssl, r);
Debug_Log("SSL_read(%zd): ERR %d", len, err);
return handle_ssl_error(err, "SSL_read");
}
Expand All @@ -248,13 +249,14 @@ ssize_t NdbSocket::ssl_peek(char *buf, size_t len) const
{
bool r;
size_t nread = 0;
int err;
{
Guard2 guard(mutex); // acquire mutex if non-null
r = SSL_peek_ex(ssl, buf, len, &nread);
if(r) return nread;
err = SSL_get_error(ssl, r);
}

if(r) return nread;
int err = SSL_get_error(ssl, r);
Debug_Log("SSL_peek(%zd): ERR %d", len, err);
return handle_ssl_error(err, "SSL_peek");
}
Expand Down

0 comments on commit d3aea14

Please sign in to comment.