File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -101,16 +101,18 @@ func (c *Conn) readInitialHandshake() error {
101101if c .capability & CLIENT_SECURE_CONNECTION != 0 {
102102// Rest of the plugin provided data (scramble)
103103
104+ // https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_handshake_v10.html
104105// $len=MAX(13, length of auth-plugin-data - 8)
106+ //
107+ // https://github.com/mysql/mysql-server/blob/1bfe02bdad6604d54913c62614bde57a055c8332/sql/auth/sql_authentication.cc#L1641-L1642
108+ // the first packet *must* have at least 20 bytes of a scramble.
109+ // if a plugin provided less, we pad it to 20 with zeros
105110rest := int (authPluginDataLen ) - 8
106- if max := 13 ; rest < max {
111+ if max := 12 + 1 ; rest < max {
107112rest = max
108113}
109- if data [pos + rest - 1 ] != 0 {
110- return errors .Errorf ("expect 0x00 after scramble, got %q" , rune (data [pos ]))
111- }
112114
113- authPluginDataPart2 := data [pos : pos + rest - 1 ]
115+ authPluginDataPart2 := data [pos : pos + rest ]
114116pos += rest
115117
116118c .salt = append (c .salt , authPluginDataPart2 ... )
You can’t perform that action at this time.
0 commit comments