parser: minor.
This commit is contained in:
parent
4008caff51
commit
59e73b24ca
@ -133,14 +133,18 @@ Parser.prototype.parseHeader = function parseHeader(data) {
|
|||||||
|
|
||||||
magic = data.readUInt32LE(0, true);
|
magic = data.readUInt32LE(0, true);
|
||||||
|
|
||||||
if (magic !== this.network.magic)
|
if (magic !== this.network.magic) {
|
||||||
return this.error('Invalid magic value: %s.', util.hex32(magic));
|
this.error('Invalid magic value: %s.', util.hex32(magic));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Count length of the cmd
|
// Count length of the cmd
|
||||||
for (i = 0; data[i + 4] !== 0 && i < 12; i++);
|
for (i = 0; data[i + 4] !== 0 && i < 12; i++);
|
||||||
|
|
||||||
if (i === 12)
|
if (i === 12) {
|
||||||
return this.error('Non NULL-terminated command.');
|
this.error('Non NULL-terminated command.');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
cmd = data.toString('ascii', 4, 4 + i);
|
cmd = data.toString('ascii', 4, 4 + i);
|
||||||
|
|
||||||
@ -149,7 +153,7 @@ Parser.prototype.parseHeader = function parseHeader(data) {
|
|||||||
if (size > common.MAX_MESSAGE) {
|
if (size > common.MAX_MESSAGE) {
|
||||||
this.waiting = 24;
|
this.waiting = 24;
|
||||||
this.error('Packet length too large: %dmb.', util.mb(size));
|
this.error('Packet length too large: %dmb.', util.mb(size));
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.waiting = size;
|
this.waiting = size;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user