Skip to content

Commit e754fd1

Browse files
author
Reinier Schoof
committed
fixed access denied error message after go-mysql-org#589
1 parent 13d123b commit e754fd1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

server/conn.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ func (c *Conn) handshake() error {
107107

108108
if err := c.readHandshakeResponse(); err != nil {
109109
if errors.Is(err, ErrAccessDenied) {
110-
usingPasswd := ER_YES
110+
var usingPasswd uint16 = ER_YES
111111
if errors.Is(err, ErrAccessDeniedNoPassword) {
112112
usingPasswd = ER_NO
113113
}
114-
err = NewDefaultError(ER_ACCESS_DENIED_ERROR, c.user, c.RemoteAddr().String(), usingPasswd)
114+
err = NewDefaultError(ER_ACCESS_DENIED_ERROR, c.user, c.RemoteAddr().String(), MySQLErrName[usingPasswd])
115115
}
116116
_ = c.writeError(err)
117117
return err

server/handshake_resp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (c *Conn) readAuthData(data []byte, pos int) (auth []byte, authLen int, new
148148
}
149149
if isNULL {
150150
// no auth length and no auth data, just \NUL, considered invalid auth data, and reject connection as MySQL does
151-
return nil, 0, 0, NewDefaultError(ER_ACCESS_DENIED_ERROR, c.RemoteAddr().String(), c.user, ER_NO)
151+
return nil, 0, 0, NewDefaultError(ER_ACCESS_DENIED_ERROR, c.RemoteAddr().String(), c.user, MySQLErrName[ER_NO])
152152
}
153153
auth = authData
154154
authLen = readBytes

0 commit comments

Comments
 (0)