Skip to content

Commit c55679a

Browse files
committed
Fail the connection if a message is larger than the configured max length after extension processing
1 parent 5b197ca commit c55679a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/websocket/driver/hybi.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,12 @@ var instance = {
452452
if (error) return this._fail('extension_error', error.message);
453453

454454
var payload = message.data;
455-
if (message.opcode === this.OPCODES.text) payload = this._encode(payload);
455+
456+
if (payload.length > this._maxLength)
457+
return this._fail('too_large', 'WebSocket frame length too large');
458+
459+
if (message.opcode === this.OPCODES.text)
460+
payload = this._encode(payload);
456461

457462
if (payload === null)
458463
return this._fail('encoding_error', 'Could not decode a text frame as UTF-8');

0 commit comments

Comments
 (0)