Skip to content

Commit d3aea14

Browse files
committed
Bug#35715333 SSL_get_error must be called in same critical section as 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
1 parent e35f76e commit d3aea14

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

storage/ndb/src/common/util/NdbSocket.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,14 @@ ssize_t NdbSocket::ssl_recv(char *buf, size_t len) const
233233
{
234234
bool r;
235235
size_t nread = 0;
236+
int err;
236237
{
237238
Guard2 guard(mutex); // acquire mutex if non-null
238239
r = SSL_read_ex(ssl, buf, len, &nread);
240+
if(r) return nread;
241+
err = SSL_get_error(ssl, r);
239242
}
240243

241-
if(r) return nread;
242-
int err = SSL_get_error(ssl, r);
243244
Debug_Log("SSL_read(%zd): ERR %d", len, err);
244245
return handle_ssl_error(err, "SSL_read");
245246
}
@@ -248,13 +249,14 @@ ssize_t NdbSocket::ssl_peek(char *buf, size_t len) const
248249
{
249250
bool r;
250251
size_t nread = 0;
252+
int err;
251253
{
252254
Guard2 guard(mutex); // acquire mutex if non-null
253255
r = SSL_peek_ex(ssl, buf, len, &nread);
256+
if(r) return nread;
257+
err = SSL_get_error(ssl, r);
254258
}
255259

256-
if(r) return nread;
257-
int err = SSL_get_error(ssl, r);
258260
Debug_Log("SSL_peek(%zd): ERR %d", len, err);
259261
return handle_ssl_error(err, "SSL_peek");
260262
}

0 commit comments

Comments
 (0)