From 287a500ce1395f6be10819eea3985851d6ba8641 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Mon, 2 Jul 2018 11:06:25 +0900 Subject: [PATCH] Fix caching_sha2_password with empty password There shouldn't be trailing NUL byte for caching_sha2_password. Fixes #825 --- auth.go | 2 +- auth_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/auth.go b/auth.go index 0b59f52ee..2f61ecd4f 100644 --- a/auth.go +++ b/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 { diff --git a/auth_test.go b/auth_test.go index 407363be4..bd0e2189c 100644 --- a/auth_test.go +++ b/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) }