From dee23060321c266efb65f657124c8a7d3a5ec225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 25 Sep 2020 14:26:39 +0200 Subject: [PATCH] Uncomplete SSL connections cause infinite loops This could be reproduced for example using mysql client and only specifying a certificate but not a key mysql -h 127.0.0.1 -P6033 --ssl-cert=file.pem --- lib/mysql_data_stream.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index dc2ed54bb..5151d4e94 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -562,6 +562,11 @@ int MySQL_Data_Stream::read_from_net() { } else { int ssl_ret=SSL_get_error(ssl, r); if (ssl_ret!=SSL_ERROR_WANT_READ && ssl_ret!=SSL_ERROR_WANT_WRITE) shut_soft(); + if (r==0 && revents==1) { + // revents returns 1 , but recv() returns 0 , so there is no data. + // Therefore the socket is already closed + shut_soft(); + } } } else { queue_w(queueIN,r);