diff --git a/lib/net/parser.js b/lib/net/parser.js index 9a54a83e..9fd3eda3 100644 --- a/lib/net/parser.js +++ b/lib/net/parser.js @@ -133,14 +133,18 @@ Parser.prototype.parseHeader = function parseHeader(data) { magic = data.readUInt32LE(0, true); - if (magic !== this.network.magic) - return this.error('Invalid magic value: %s.', util.hex32(magic)); + if (magic !== this.network.magic) { + this.error('Invalid magic value: %s.', util.hex32(magic)); + return null; + } // Count length of the cmd for (i = 0; data[i + 4] !== 0 && i < 12; i++); - if (i === 12) - return this.error('Non NULL-terminated command.'); + if (i === 12) { + this.error('Non NULL-terminated command.'); + return null; + } cmd = data.toString('ascii', 4, 4 + i); @@ -149,7 +153,7 @@ Parser.prototype.parseHeader = function parseHeader(data) { if (size > common.MAX_MESSAGE) { this.waiting = 24; this.error('Packet length too large: %dmb.', util.mb(size)); - return; + return null; } this.waiting = size;