Skip to content

Commit 2dc09f6

Browse files
bzozTrott
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: 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]>
1 parent 211df3f commit 2dc09f6

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
@@ -53,6 +53,7 @@ function sendEnd(socket) {
5353
}
5454

5555
function parseWSFrame(buffer, handler) {
56+
// Protocol described in https://tools.ietf.org/html/rfc6455#section-5
5657
if (buffer.length < 2)
5758
return 0;
5859
if (buffer[0] === 0x88 && buffer[1] === 0x00) {
@@ -68,7 +69,8 @@ function parseWSFrame(buffer, handler) {
6869
dataLen = buffer.readUInt16BE(2);
6970
bodyOffset = 4;
7071
} else if (dataLen === 127) {
71-
dataLen = buffer.readUInt32BE(2);
72+
assert(buffer[2] === 0 && buffer[3] === 0, 'Inspector message too big');
73+
dataLen = buffer.readUIntBE(4, 6);
7274
bodyOffset = 10;
7375
}
7476
if (buffer.length < bodyOffset + dataLen)

0 commit comments

Comments
 (0)