From 54d74dfccaab60e2909fce6ae674ed20907fce81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 6 May 2019 00:20:03 +1000 Subject: [PATCH] Fix bug in add_ldap_comment_to_pkt when query starts with a comment --- lib/MySQL_Session.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index d16e54782..552e77fe0 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -5326,6 +5326,12 @@ void MySQL_Session::add_ldap_comment_to_pkt(PtrSize_t *_pkt) { void *idx = memchr((char *)_pkt->ptr+5, ' ', _pkt->size-5); if (idx) { size_t first_word_len = (char *)idx - (char *)_pkt->ptr - 5; + if (((char *)_pkt->ptr+5)[0]=='/' && ((char *)_pkt->ptr+5)[1]=='*') { + b[1]=' '; + b[2]=' '; + b[strlen(b)-1] = ' '; + b[strlen(b)-2] = ' '; + } memcpy(_c, (char *)_pkt->ptr+5, first_word_len); _c+= first_word_len; memcpy(_c,b,strlen(b)); @@ -5339,6 +5345,7 @@ void MySQL_Session::add_ldap_comment_to_pkt(PtrSize_t *_pkt) { l_free(_pkt->size,_pkt->ptr); _pkt->size = _pkt->size + strlen(b); _pkt->ptr = _new_pkt.ptr; + free(b); } void MySQL_Session::finishQuery(MySQL_Data_Stream *myds, MySQL_Connection *myconn, bool prepared_stmt_with_no_params) {