From 91b02c7186b4bef27ee153afdcf672f4412e6a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sat, 16 Feb 2019 22:41:13 +1100 Subject: [PATCH] Fix crash if login without password #1893 --- lib/MySQL_Protocol.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/MySQL_Protocol.cpp b/lib/MySQL_Protocol.cpp index 80e4e478b..76f337a42 100644 --- a/lib/MySQL_Protocol.cpp +++ b/lib/MySQL_Protocol.cpp @@ -1507,8 +1507,10 @@ bool MySQL_Protocol::process_pkt_handshake_response(unsigned char *pkt, unsigned } else { db = NULL; } - if (pass[pass_len-1] == 0) { - pass_len--; // remove the extra 0 if present + if (pass_len) { + if (pass[pass_len-1] == 0) { + pass_len--; // remove the extra 0 if present + } } if (_ptr+len > pkt) { if (capabilities & CLIENT_PLUGIN_AUTH) {