Skip to content

Commit

Permalink
Annotation from CI
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfcod committed Sep 23, 2024
1 parent 485844a commit 14875db
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/core/operations/WebSocketDecode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,35 @@ class WebSocketDecode extends Operation {
throw new OperationError("Expected size: 2 bytes");
}

let b0 = buf[0];
let b1 = buf[1];
const b0 = buf[0];
const b1 = buf[1];

const fin = (b0 & 0x80) === 0x80 ? true : false;
const opcode = WEBSOCKET_OPCODE[b0 & 0x7f];
let payloadLength = (b1 & 0x7f);

pos = 2;
const mask = (b1 & 0x80) === 0x80 ? true : false;
const mask_size = (mask) ? 4 : 0;
const maskSize = (mask) ? 4 : 0;

if (payloadLength < 126) {
/** payload is less of 126 bytes */
if (buf.length < (pos + payloadLength + mask_size))
throw new OperationError(`Expected size: ${(pos + payloadLength + mask_size)}`);
} else if (payloadLength == 126) {
if (buf.length < (pos + payloadLength + maskSize))
throw new OperationError(`Expected size: ${(pos + payloadLength + maskSize)}`);
} else if (payloadLength === 126) {
/** payload is 2 bytes */
pos += 2;
payloadLength = buf.readUInt16BE(2);

if (buf.length < (pos + payloadLength + mask_size))
throw new OperationError(`Expected size: ${(pos + payloadLength + mask_size)}`);
if (buf.length < (pos + payloadLength + maskSize))
throw new OperationError(`Expected size: ${(pos + payloadLength + maskSize)}`);

} else if (payloadLength == 127) {
} else if (payloadLength === 127) {
pos += 8;
payloadLength = buf.readUInt64BE(2);

if (buf.length < (pos + payloadLength + mask_size))
throw new OperationError(`Expected size: ${(pos + payloadLength + mask_size)}`);
if (buf.length < (pos + payloadLength + maskSize))
throw new OperationError(`Expected size: ${(pos + payloadLength + maskSize)}`);
}

let maskBytes = Buffer.alloc(4);

Check failure on line 74 in src/core/operations/WebSocketDecode.mjs

View workflow job for this annotation

GitHub Actions / main

'maskBytes' is never reassigned. Use 'const' instead
Expand Down

0 comments on commit 14875db

Please sign in to comment.