-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: read proper inspector message size #14596
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,7 @@ function parseWSFrame(buffer, handler) { | |
dataLen = buffer.readUInt16BE(2); | ||
bodyOffset = 4; | ||
} else if (dataLen === 127) { | ||
dataLen = buffer.readUInt32BE(2); | ||
dataLen = buffer.readUIntBE(2, 8); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, dataLen = buffer.readUInt32BE(2);
if (dataLen > Math.pow(2, 53 - 32) - 1) {
assert.fail('Frame size is bigger than `Number.MAX_SAFE_INTEGER`');
}
dataLen += buffer.readUInt32BE(6); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will be easier to assert that buffer[1] and buffer[2] equal 0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, the max value for a UInt32 is 4294967295, vastly lower than Number.MAX_SAFE_INTEGER, so the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Trott yes but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's safe to assume that frames are not bigger than dataLen = buffer.readUInt32BE(6); |
||
bodyOffset = 10; | ||
} | ||
if (buffer.length < bodyOffset + dataLen) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the docs for
buf.readUIntBE()
state that the second argumentMust satisfy: 0 < byteLength <= 6