Skip to content

Commit dd9d356

Browse files
authored
Put zero filler into the SSL handshake packet. (#1066)
According to the linked documentation at http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest SSLRequest packet should have zero filler similar to the regular handshake request, but now the driver puts zeros only in the regular request. Luckily vanilla MySQL doesn't rely on this zero filler and doesn't verify its presence, thus the driver worked fine so far. But MySQL can change to rely on zeros at any point. The problem was discovered while testing against a customized MySQL.
1 parent 3d8a029 commit dd9d356

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packets.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
349349
return errors.New("unknown collation")
350350
}
351351

352+
// Filler [23 bytes] (all 0x00)
353+
pos := 13
354+
for ; pos < 13+23; pos++ {
355+
data[pos] = 0
356+
}
357+
352358
// SSL Connection Request Packet
353359
// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest
354360
if mc.cfg.tls != nil {
@@ -367,12 +373,6 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
367373
mc.buf.nc = tlsConn
368374
}
369375

370-
// Filler [23 bytes] (all 0x00)
371-
pos := 13
372-
for ; pos < 13+23; pos++ {
373-
data[pos] = 0
374-
}
375-
376376
// User [null terminated string]
377377
if len(mc.cfg.User) > 0 {
378378
pos += copy(data[pos:], mc.cfg.User)

0 commit comments

Comments
 (0)