Skip to content

Commit

Permalink
Apply masking to messages once the payload has been placed in the fra…
Browse files Browse the repository at this point in the history
…me buffer rather than mutating the original message.
  • Loading branch information
jcoglan committed Apr 27, 2016
1 parent 2be8295 commit 6a92cac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/websocket/driver/hybi.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ var instance = {
buffer.writeUInt32BE(length % 0x100000000, 6); buffer.writeUInt32BE(length % 0x100000000, 6);
} }


frame.payload.copy(buffer, offset);

if (frame.masked) { if (frame.masked) {
frame.maskingKey.copy(buffer, header); frame.maskingKey.copy(buffer, header);
Hybi.mask(frame.payload, frame.maskingKey).copy(buffer, offset); Hybi.mask(buffer, frame.maskingKey, offset);
} else {
frame.payload.copy(buffer, offset);
} }


this._write(buffer); this._write(buffer);
Expand Down

0 comments on commit 6a92cac

Please sign in to comment.