Fix ssl related problems when ssl_new returns nil

This commit is contained in:
lazio579 2018-09-28 16:21:05 +08:00
parent 8034a07e4b
commit 17b443c49e
2 changed files with 20 additions and 10 deletions

View File

@ -164,10 +164,15 @@ NETWORK_MYSQLD_PLUGIN_PROTO(server_read_auth) {
#ifdef HAVE_OPENSSL
if (auth->ssl_request) {
network_ssl_create_connection(con->client, NETWORK_SSL_SERVER);
g_string_free(g_queue_pop_tail(con->client->recv_queue->chunks), TRUE);
con->state = ST_FRONT_SSL_HANDSHAKE;
return NETWORK_SOCKET_SUCCESS;
if (network_ssl_create_connection(con->client, NETWORK_SSL_SERVER) == FALSE) {
network_mysqld_con_send_error_full(con->client, C("SSL server failed"), 1045, "28000");
network_mysqld_auth_response_free(auth);
return NETWORK_SOCKET_ERROR;
} else {
g_string_free(g_queue_pop_tail(con->client->recv_queue->chunks), TRUE);
con->state = ST_FRONT_SSL_HANDSHAKE;
return NETWORK_SOCKET_SUCCESS;
}
}
#endif
con->client->response = auth;

View File

@ -152,13 +152,18 @@ do_read_auth(network_mysqld_con *con)
#ifdef HAVE_OPENSSL
if (con->srv->ssl && auth->ssl_request) {
network_ssl_create_connection(recv_sock, NETWORK_SSL_SERVER);
g_string_free(g_queue_pop_tail(recv_sock->recv_queue->chunks), TRUE);
if (recv_sock->recv_queue->chunks->length > 0) {
g_warning("%s: client-recv-queue-len = %d", G_STRLOC, recv_sock->recv_queue->chunks->length);
if (network_ssl_create_connection(recv_sock, NETWORK_SSL_SERVER) == FALSE) {
network_mysqld_con_send_error_full(con->client, C("SSL server failed"), 1045, "28000");
network_mysqld_auth_response_free(auth);
return NETWORK_SOCKET_ERROR;
} else {
g_string_free(g_queue_pop_tail(recv_sock->recv_queue->chunks), TRUE);
if (recv_sock->recv_queue->chunks->length > 0) {
g_warning("%s: client-recv-queue-len = %d", G_STRLOC, recv_sock->recv_queue->chunks->length);
}
con->state = ST_FRONT_SSL_HANDSHAKE;
return NETWORK_SOCKET_SUCCESS;
}
con->state = ST_FRONT_SSL_HANDSHAKE;
return NETWORK_SOCKET_SUCCESS;
}
#endif
if (!(auth->client_capabilities & CLIENT_PROTOCOL_41)) {