From 6dd8a4d8ba16bf5ee724c55bcc8c05f57026dd99 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 19 Aug 2019 17:44:35 +1000 Subject: [PATCH] Don't try to parse unknown session track blocks. Fixes #989 --- lib/packets/resultset_header.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/packets/resultset_header.js b/lib/packets/resultset_header.js index e0f77071ae..95ff56a534 100644 --- a/lib/packets/resultset_header.js +++ b/lib/packets/resultset_header.js @@ -15,6 +15,7 @@ class ResultSetHeader { const encoding = connection.serverEncoding; const flags = connection._handshakePacket.capabilityFlags; const isSet = function(flag) { + console.log('isSet?', flag, ClientConstants[flag]); return flags & ClientConstants[flag]; }; if (packet.buffer[packet.offset] !== 0) { @@ -36,7 +37,9 @@ class ResultSetHeader { } let stateChanges = null; if (isSet('SESSION_TRACK') && packet.offset < packet.end) { + const sessionInfoTypes = require('../constants/session_track.js'); this.info = packet.readLengthCodedString(encoding); + if (this.serverStatus && ServerSatusFlags.SERVER_SESSION_STATE_CHANGED) { // session change info record - see // https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html#cs-sect-packet-ok-sessioninfo @@ -48,7 +51,6 @@ class ResultSetHeader { stateChanges = { systemVariables: {}, schema: null, - // gtids: {}, trackStateChange: null }; } @@ -56,23 +58,23 @@ class ResultSetHeader { type = packet.readInt8(); len = packet.readLengthCodedNumber(); stateEnd = packet.offset + len; - key = packet.readLengthCodedString(encoding); - if (type === 0) { + if (type === sessionInfoTypes.SYSTEM_VARIABLES) { + key = packet.readLengthCodedString(encoding); const val = packet.readLengthCodedString(encoding); stateChanges.systemVariables[key] = val; if (key === 'character_set_client') { const charsetNumber = EncodingToCharset[val]; connection.config.charsetNumber = charsetNumber; } - } else if (type === 1) { - // TODO double check it's supposed to be the only value, not a list. + } else if (type === sessionInfoTypes.SCHEMA) { + key = packet.readLengthCodedString(encoding); stateChanges.schema = key; - } else if (type === 2) { + } else if (type === sessionInfoTypes.STATE_CHANGE) { stateChanges.trackStateChange = packet.readLengthCodedString( encoding ); } else { - // GTIDs (type == 3) or unknown type - just skip for now + // unsupported session track type. For now just ignore } packet.offset = stateEnd; }