Skip to content

Commit 8b9a05c

Browse files
bzozMylesBorins
authored andcommitted
test: read proper inspector message size
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]>
1 parent 3a6392b commit 8b9a05c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/inspector/inspector-helper.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function send(socket, message, id, callback) {
4848
}
4949

5050
function parseWSFrame(buffer, handler) {
51+
// Protocol described in https://tools.ietf.org/html/rfc6455#section-5
5152
if (buffer.length < 2)
5253
return 0;
5354
assert.strictEqual(0x81, buffer[0]);
@@ -59,7 +60,8 @@ function parseWSFrame(buffer, handler) {
5960
dataLen = buffer.readUInt16BE(2);
6061
bodyOffset = 4;
6162
} else if (dataLen === 127) {
62-
dataLen = buffer.readUInt32BE(2);
63+
assert(buffer[2] === 0 && buffer[3] === 0, 'Inspector message too big');
64+
dataLen = buffer.readUIntBE(4, 6);
6365
bodyOffset = 10;
6466
}
6567
if (buffer.length < bodyOffset + dataLen)

0 commit comments

Comments
 (0)