From a6ded810f24f197e41377247ebef608b88c4a710 Mon Sep 17 00:00:00 2001 From: Donghang Lin Date: Mon, 23 Sep 2019 14:45:16 -0700 Subject: [PATCH] fix server response packet decoding for empty password duing connection handshake phase --- server/handshake_resp.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/handshake_resp.go b/server/handshake_resp.go index f03c5c23b..4edef88df 100644 --- a/server/handshake_resp.go +++ b/server/handshake_resp.go @@ -143,15 +143,16 @@ func (c *Conn) readAuthData(data []byte, pos int) ([]byte, int, int, error) { } auth = authData authLen = readBytes - } else { + } else if c.capability&CLIENT_SECURE_CONNECTION != 0 { //auth length and auth authLen = int(data[pos]) pos++ auth = data[pos : pos+authLen] - if authLen == 0 { - // skip the next \NUL in case the password is empty - pos++ - } + } else { + authLen = bytes.IndexByte(data[pos:], 0x00) + auth = data[pos : pos+authLen] + // account for last NUL + authLen++ } return auth, authLen, pos, nil }