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: nodejs#14596
Fixes: nodejs#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 Trott committed Aug 4, 2017
1 parent 211df3f commit 2dc09f6
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 @@ -53,6 +53,7 @@ function sendEnd(socket) {
}

function parseWSFrame(buffer, handler) {
// Protocol described in https://tools.ietf.org/html/rfc6455#section-5
if (buffer.length < 2)
return 0;
if (buffer[0] === 0x88 && buffer[1] === 0x00) {
Expand All @@ -68,7 +69,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 2dc09f6

Please sign in to comment.