Skip to content

Commit

Permalink
Fix handling zero byte string for session state changed (vitessio#11071
Browse files Browse the repository at this point in the history
…) (vitessio#996)

On MySQL 8.0 it's possible we get back a zero length state for session
state changed information. In this case, we treat this as no data being
present and continue.

This was exposed in vitessio#11026 but
I'm extracted this as a separate fix until that lands since this can
trigger spurious errors when it shouldn't.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
  • Loading branch information
dbussink authored Aug 23, 2022
1 parent 6bc0171 commit 5bf4fbf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/mysql/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1470,10 +1470,15 @@ func (c *Conn) parseOKPacket(in []byte) (*PacketOK, error) {
if c.Capabilities&uint32(CapabilityClientSessionTrack) == CapabilityClientSessionTrack {
// session tracking
if statusFlags&ServerSessionStateChanged == ServerSessionStateChanged {
_, ok := data.readLenEncInt()
length, ok := data.readLenEncInt()
if !ok {
return fail("invalid OK packet session state change length: %v", data)
}
// In case we have a zero length string, there's no additional information so
// we can return the packet.
if length == 0 {
return packetOK, nil
}
sscType, ok := data.readByte()
if !ok {
return fail("invalid OK packet session state change type: %v", sscType)
Expand Down

0 comments on commit 5bf4fbf

Please sign in to comment.