aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node_modules/undici/lib/web/websocket/receiver.js
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-03-14 12:19:48 +0100
committerEgor Tensin <egor@tensin.name>2026-03-14 12:19:48 +0100
commit5736345440e43ac7f8d72c748c6b959bee5f8aa8 (patch)
tree367b7d90a8d2e199b70a196a1a91c2aa267c5633 /node_modules/undici/lib/web/websocket/receiver.js
parentMerge pull request #8 from egor-tensin/dependabot/npm_and_yarn/undici-6.24.1 (diff)
downloadcleanup-path-5736345440e43ac7f8d72c748c6b959bee5f8aa8.tar.gz
cleanup-path-5736345440e43ac7f8d72c748c6b959bee5f8aa8.zip
wait, what the hell? doesn't Dependabot update node_modules as well?
Diffstat (limited to 'node_modules/undici/lib/web/websocket/receiver.js')
-rw-r--r--node_modules/undici/lib/web/websocket/receiver.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/node_modules/undici/lib/web/websocket/receiver.js b/node_modules/undici/lib/web/websocket/receiver.js
index 581c251..e7f7512 100644
--- a/node_modules/undici/lib/web/websocket/receiver.js
+++ b/node_modules/undici/lib/web/websocket/receiver.js
@@ -37,6 +37,10 @@ class ByteParser extends Writable {
/** @type {Map<string, PerMessageDeflate>} */
#extensions
+ /**
+ * @param {import('./websocket').WebSocket} ws
+ * @param {Map<string, string>|null} extensions
+ */
constructor (ws, extensions) {
super()
@@ -179,6 +183,7 @@ class ByteParser extends Writable {
const buffer = this.consume(8)
const upper = buffer.readUInt32BE(0)
+ const lower = buffer.readUInt32BE(4)
// 2^31 is the maximum bytes an arraybuffer can contain
// on 32-bit systems. Although, on 64-bit systems, this is
@@ -186,14 +191,12 @@ class ByteParser extends Writable {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/common/globals.h;drc=1946212ac0100668f14eb9e2843bdd846e510a1e;bpv=1;bpt=1;l=1275
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-array-buffer.h;l=34;drc=1946212ac0100668f14eb9e2843bdd846e510a1e
- if (upper > 2 ** 31 - 1) {
+ if (upper !== 0 || lower > 2 ** 31 - 1) {
failWebsocketConnection(this.ws, 'Received payload length > 2^31 bytes.')
return
}
- const lower = buffer.readUInt32BE(4)
-
- this.#info.payloadLength = (upper << 8) + lower
+ this.#info.payloadLength = lower
this.#state = parserStates.READ_DATA
} else if (this.#state === parserStates.READ_DATA) {
if (this.#byteOffset < this.#info.payloadLength) {
@@ -223,7 +226,7 @@ class ByteParser extends Writable {
} else {
this.#extensions.get('permessage-deflate').decompress(body, this.#info.fin, (error, data) => {
if (error) {
- closeWebSocketConnection(this.ws, 1007, error.message, error.message.length)
+ failWebsocketConnection(this.ws, error.message)
return
}