-
-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1004 from sidorares/fix/session-track
Fix crashing when session info packet does not start with length-coded string
- Loading branch information
Showing
3 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
exports.SYSTEM_VARIABLES = 0; | ||
exports.SCHEMA = 1; | ||
exports.STATE_CHANGE = 2; | ||
exports.STATE_GTIDS = 3; | ||
exports.TRANSACTION_CHARACTERISTICS = 4; | ||
exports.TRANSACTION_STATE = 5; | ||
|
||
exports.FIRST_KEY = exports.SYSTEM_VARIABLES; | ||
exports.LAST_KEY = exports.TRANSACTION_STATE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const Packet = require('../../../lib/packets/packet'); | ||
const ResultSetHeader = require('../../../lib/packets/resultset_header.js'); | ||
const clientConstants = require('../../../lib/constants/client'); | ||
|
||
const mockConnection = { | ||
config: {}, | ||
serverEncoding: 'utf8', | ||
_handshakePacket: { | ||
capabilityFlags: clientConstants.PROTOCOL_41 + clientConstants.SESSION_TRACK | ||
} | ||
}; | ||
|
||
const mkpacket = str => { | ||
const buf = Buffer.from(str.split(/[ \n]+/).join(''), 'hex'); | ||
return new Packet(0, buf, 0, buf.length); | ||
}; | ||
|
||
// regression examples from https://github.com/sidorares/node-mysql2/issues/989 | ||
|
||
assert.doesNotThrow(() => { | ||
const packet = mkpacket( | ||
`1b 00 00 01 | ||
00 | ||
01 fe 65 96 fc 02 00 00 00 00 03 40 00 00 00 0a 14 08 fe 60 63 9b 05 00 00 00 | ||
` | ||
); | ||
new ResultSetHeader(packet, mockConnection); | ||
}); | ||
|
||
assert.doesNotThrow(() => { | ||
const packet = mkpacket( | ||
`13 00 00 01 00 01 00 02 40 00 00 00 0a 14 08 fe 18 25 e7 06 00 00 00` | ||
); | ||
new ResultSetHeader(packet, mockConnection); | ||
}); |