From a7d00854eb55735e98e45983c89a144f05ab212d Mon Sep 17 00:00:00 2001 From: Kevin Freund Date: Tue, 20 Jun 2017 13:55:20 -0700 Subject: [PATCH] Fixed a buffer starvation issue, where the BER length is cut off at the end of the currently available buffer. --- lib/klv.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/klv.js b/lib/klv.js index e8123ae..32ed5f5 100644 --- a/lib/klv.js +++ b/lib/klv.js @@ -61,6 +61,7 @@ KLVStream.prototype.write = function(data) { // Emit the length else if (this.state === KLV_STATES.LENGTH) { var decodedBER = decodeBER(this.buffer); + if (typeof decodedBER.value === 'undefined') { return true; } this.buffer = this.buffer.slice(decodedBER.bytesRead); this.state = KLV_STATES.VALUE; this.valueLength = decodedBER.value; // Record to track the value