Skip to content

Commit 40afdbe

Browse files
dhlinsiddontang
authored andcommitted
fix server response packet decoding for empty password duing connection handshake phase (#430)
1 parent 7037937 commit 40afdbe

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

server/handshake_resp.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,16 @@ func (c *Conn) readAuthData(data []byte, pos int) ([]byte, int, int, error) {
143143
}
144144
auth = authData
145145
authLen = readBytes
146-
} else {
146+
} else if c.capability&CLIENT_SECURE_CONNECTION != 0 {
147147
//auth length and auth
148148
authLen = int(data[pos])
149149
pos++
150150
auth = data[pos : pos+authLen]
151-
if authLen == 0 {
152-
// skip the next \NUL in case the password is empty
153-
pos++
154-
}
151+
} else {
152+
authLen = bytes.IndexByte(data[pos:], 0x00)
153+
auth = data[pos : pos+authLen]
154+
// account for last NUL
155+
authLen++
155156
}
156157
return auth, authLen, pos, nil
157158
}

0 commit comments

Comments
 (0)