浏览代码

Fix caching_sha2_password with empty password (#826)

There shouldn't be trailing NUL byte for caching_sha2_password.

Fixes #825
INADA Naoki 7 年之前
父节点
当前提交
885c931975
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      auth.go
  2. 1 1
      auth_test.go

+ 1 - 1
auth.go

@@ -241,7 +241,7 @@ func (mc *mysqlConn) auth(authData []byte, plugin string) ([]byte, bool, error)
 	switch plugin {
 	case "caching_sha2_password":
 		authResp := scrambleSHA256Password(authData, mc.cfg.Passwd)
-		return authResp, (authResp == nil), nil
+		return authResp, false, nil
 
 	case "mysql_old_password":
 		if !mc.cfg.AllowOldPasswords {

+ 1 - 1
auth_test.go

@@ -764,7 +764,7 @@ func TestAuthSwitchCachingSHA256PasswordEmpty(t *testing.T) {
 		t.Errorf("got error: %v", err)
 	}
 
-	expectedReply := []byte{1, 0, 0, 3, 0}
+	expectedReply := []byte{0, 0, 0, 3}
 	if !bytes.Equal(conn.written, expectedReply) {
 		t.Errorf("got unexpected data: %v", conn.written)
 	}