Skip to content

Commit

Permalink
test: read proper inspector message size
Browse files Browse the repository at this point in the history
Fix a bug when messages bigger than 64kb where incorrectly parsed by
the inspector-helper.

PR-URL: #14596
Fixes: #14507
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Eugene Ostroukhov <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
bzoz authored and MylesBorins committed Sep 19, 2017
1 parent 3a6392b commit 8b9a05c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/inspector/inspector-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function send(socket, message, id, callback) {
}

function parseWSFrame(buffer, handler) {
// Protocol described in https://tools.ietf.org/html/rfc6455#section-5
if (buffer.length < 2)
return 0;
assert.strictEqual(0x81, buffer[0]);
Expand All @@ -59,7 +60,8 @@ function parseWSFrame(buffer, handler) {
dataLen = buffer.readUInt16BE(2);
bodyOffset = 4;
} else if (dataLen === 127) {
dataLen = buffer.readUInt32BE(2);
assert(buffer[2] === 0 && buffer[3] === 0, 'Inspector message too big');
dataLen = buffer.readUIntBE(4, 6);
bodyOffset = 10;
}
if (buffer.length < bodyOffset + dataLen)
Expand Down

0 comments on commit 8b9a05c

Please sign in to comment.