bip151: max message size.
This commit is contained in:
parent
94af094322
commit
73deb5430e
@ -79,7 +79,6 @@ BIP151Stream.prototype.init = function init(publicKey) {
|
||||
};
|
||||
|
||||
BIP151Stream.prototype.maybeRekey = function maybeRekey(data) {
|
||||
var self = this;
|
||||
this.processed += data.length;
|
||||
if (this.processed >= this.highWaterMark) {
|
||||
this.processed -= this.highWaterMark;
|
||||
@ -171,7 +170,11 @@ BIP151Stream.prototype.feed = function feed(data) {
|
||||
|
||||
this.waiting = this.decryptSize(chunk) + 16;
|
||||
|
||||
if (this.waiting - 32 > constants.MAX_MESSAGE) {
|
||||
// Allow 3 batched packets of max message size.
|
||||
// Not technically standard, but this protects us
|
||||
// from buffering tons of data due to either an
|
||||
// potential dos'er or a cipher state mismatch.
|
||||
if (this.waiting - 32 > constants.MAX_MESSAGE * 3) {
|
||||
this.waiting = 0;
|
||||
this.emit('error', new Error('Packet too large.'));
|
||||
continue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user