Permalink
Browse files

Apply masking to messages once the payload has been placed in the fra…

…me buffer rather than mutating the original message.
  • Loading branch information...
1 parent 2be8295 commit 6a92cacf627c67fe0c96c5453c363817e68dbed9 @jcoglan jcoglan committed Apr 27, 2016
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/websocket/driver/hybi.js
@@ -264,11 +264,11 @@ var instance = {
buffer.writeUInt32BE(length % 0x100000000, 6);
}
+ frame.payload.copy(buffer, offset);
+
if (frame.masked) {
frame.maskingKey.copy(buffer, header);
- Hybi.mask(frame.payload, frame.maskingKey).copy(buffer, offset);
- } else {
- frame.payload.copy(buffer, offset);
+ Hybi.mask(buffer, frame.maskingKey, offset);
}
this._write(buffer);

0 comments on commit 6a92cac

Please sign in to comment.