From 756c1cb4335c5cc24dd31e5d7aad0744a1d80ed0 Mon Sep 17 00:00:00 2001 From: Reinier Schoof Date: Sat, 26 Jun 2021 20:52:51 +0200 Subject: [PATCH 1/2] fixed access denied error message after #589 --- server/conn.go | 4 ++-- server/handshake_resp.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/conn.go b/server/conn.go index 19bdae8ba..2e819309c 100644 --- a/server/conn.go +++ b/server/conn.go @@ -107,11 +107,11 @@ func (c *Conn) handshake() error { if err := c.readHandshakeResponse(); err != nil { if errors.Is(err, ErrAccessDenied) { - usingPasswd := ER_YES + var usingPasswd uint16 = ER_YES if errors.Is(err, ErrAccessDeniedNoPassword) { usingPasswd = ER_NO } - err = NewDefaultError(ER_ACCESS_DENIED_ERROR, c.user, c.RemoteAddr().String(), usingPasswd) + err = NewDefaultError(ER_ACCESS_DENIED_ERROR, c.user, c.RemoteAddr().String(), MySQLErrName[usingPasswd]) } _ = c.writeError(err) return err diff --git a/server/handshake_resp.go b/server/handshake_resp.go index f2777bb7e..83ea68933 100644 --- a/server/handshake_resp.go +++ b/server/handshake_resp.go @@ -148,7 +148,7 @@ func (c *Conn) readAuthData(data []byte, pos int) (auth []byte, authLen int, new } if isNULL { // no auth length and no auth data, just \NUL, considered invalid auth data, and reject connection as MySQL does - return nil, 0, 0, NewDefaultError(ER_ACCESS_DENIED_ERROR, c.RemoteAddr().String(), c.user, ER_NO) + return nil, 0, 0, NewDefaultError(ER_ACCESS_DENIED_ERROR, c.RemoteAddr().String(), c.user, MySQLErrName[ER_NO]) } auth = authData authLen = readBytes From 74443784755b20413ee92e96091f92a429ac8731 Mon Sep 17 00:00:00 2001 From: Reinier Schoof Date: Sat, 26 Jun 2021 20:53:30 +0200 Subject: [PATCH 2/2] fixed access denied error on empty auth data --- server/handshake_resp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/handshake_resp.go b/server/handshake_resp.go index 83ea68933..efdf511e5 100644 --- a/server/handshake_resp.go +++ b/server/handshake_resp.go @@ -148,7 +148,7 @@ func (c *Conn) readAuthData(data []byte, pos int) (auth []byte, authLen int, new } if isNULL { // no auth length and no auth data, just \NUL, considered invalid auth data, and reject connection as MySQL does - return nil, 0, 0, NewDefaultError(ER_ACCESS_DENIED_ERROR, c.RemoteAddr().String(), c.user, MySQLErrName[ER_NO]) + return nil, 0, 0, NewDefaultError(ER_ACCESS_DENIED_ERROR, c.user, c.RemoteAddr().String(), MySQLErrName[ER_NO]) } auth = authData authLen = readBytes