Skip to content

Commit 99ff426

Browse files
authored
Fix caching_sha2_password with empty password (go-sql-driver#826)
There shouldn't be trailing NUL byte for caching_sha2_password. Fixes go-sql-driver#825
1 parent 447ae1f commit 99ff426

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

auth.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (mc *mysqlConn) auth(authData []byte, plugin string) ([]byte, bool, error)
241241
switch plugin {
242242
case "caching_sha2_password":
243243
authResp := scrambleSHA256Password(authData, mc.cfg.Passwd)
244-
return authResp, (authResp == nil), nil
244+
return authResp, false, nil
245245

246246
case "mysql_old_password":
247247
if !mc.cfg.AllowOldPasswords {

auth_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ func TestAuthSwitchCachingSHA256PasswordEmpty(t *testing.T) {
764764
t.Errorf("got error: %v", err)
765765
}
766766

767-
expectedReply := []byte{1, 0, 0, 3, 0}
767+
expectedReply := []byte{0, 0, 0, 3}
768768
if !bytes.Equal(conn.written, expectedReply) {
769769
t.Errorf("got unexpected data: %v", conn.written)
770770
}

0 commit comments

Comments
 (0)