From 72aefea1ed08a602aaaaef9dd61d76c320f1cb74 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Tue, 22 Oct 2024 15:23:40 +0500 Subject: [PATCH] Fixed crash caused by sending single semicolon (;) on admin interface --- lib/ProxySQL_Admin.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index f80826327..4b3c3b770 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -3761,12 +3761,20 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { if (query_no_space_length) { // fix bug #925 - while (query_no_space[query_no_space_length-1]==';' || query_no_space[query_no_space_length-1]==' ') { + while (query_no_space_length && + (query_no_space[query_no_space_length-1]==';' || query_no_space[query_no_space_length-1]==' ')) { query_no_space_length--; query_no_space[query_no_space_length]=0; } } + if (query_no_space_length == 0) { + proxy_warning("Empty query\n"); + SPA->send_MySQL_ERR(&sess->client_myds->myprot, (char*)"Empty query"); + run_query = false; + goto __run_query; + } + // add global mutex, see bug #1188 pthread_mutex_lock(&pa->sql_query_global_mutex);