Przeglądaj źródła

Fix caching_sha2_password with empty password (#826)

There shouldn't be trailing NUL byte for caching_sha2_password.

Fixes #825
INADA Naoki 7 lat temu
rodzic
commit
885c931975
2 zmienionych plików z 2 dodań i 2 usunięć
  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)
 	}