Skip to content

Commit

Permalink
added proper return after reserved field error
Browse files Browse the repository at this point in the history
  • Loading branch information
einaros committed Nov 14, 2011
1 parent 27714d7 commit 2b28c46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/transports/websocket/hybi-07-12.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,9 @@ Parser.prototype.expect = function(what, length, handler) {
*/

Parser.prototype.processPacket = function (data) {
if ((data[0] & 0x70) != 0) this.error('reserved fields must be empty');
if ((data[0] & 0x70) != 0) {
this.error('reserved fields must be empty');
}
this.state.lastFragment = (data[0] & 0x80) == 0x80;
this.state.masked = (data[1] & 0x80) == 0x80;
var opcode = data[0] & 0xf;
Expand Down
5 changes: 4 additions & 1 deletion lib/transports/websocket/hybi-16.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ Parser.prototype.expect = function(what, length, handler) {
*/

Parser.prototype.processPacket = function (data) {
if ((data[0] & 0x70) != 0) this.error('reserved fields must be empty');
if ((data[0] & 0x70) != 0) {
this.error('reserved fields must be empty');
return;
}
this.state.lastFragment = (data[0] & 0x80) == 0x80;
this.state.masked = (data[1] & 0x80) == 0x80;
var opcode = data[0] & 0xf;
Expand Down

0 comments on commit 2b28c46

Please sign in to comment.