Comparing version 3.0.0 to 3.0.1
11
bl.js
@@ -188,8 +188,9 @@ 'use strict' | ||
this._bufs[i].copy(dst, bufoff, start) | ||
bufoff += l | ||
} else { | ||
this._bufs[i].copy(dst, bufoff, start, start + bytes) | ||
bufoff += l | ||
break | ||
} | ||
bufoff += l | ||
bytes -= l | ||
@@ -201,2 +202,5 @@ | ||
// safeguard so that we don't return uninitialized memory | ||
if (dst.length > bufoff) return dst.slice(0, bufoff) | ||
return dst | ||
@@ -237,2 +241,7 @@ } | ||
BufferList.prototype.consume = function consume (bytes) { | ||
// first, normalize the argument, in accordance with how Buffer does it | ||
bytes = Math.trunc(bytes) | ||
// do nothing if not a positive number | ||
if (Number.isNaN(bytes) || bytes <= 0) return this | ||
while (this._bufs.length) { | ||
@@ -239,0 +248,0 @@ if (bytes >= this._bufs[0].length) { |
{ | ||
"name": "bl", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!", | ||
@@ -5,0 +5,0 @@ "main": "bl.js", |
@@ -434,2 +434,18 @@ 'use strict' | ||
tape('uninitialized memory', function (t) { | ||
const secret = crypto.randomBytes(256) | ||
for (let i = 0; i < 1e6; i++) { | ||
const clone = Buffer.from(secret) | ||
const bl = new BufferList() | ||
bl.append(Buffer.from('a')) | ||
bl.consume(-1024) | ||
const buf = bl.slice(1) | ||
if (buf.indexOf(clone) !== -1) { | ||
t.fail(`Match (at ${i})`) | ||
break | ||
} | ||
} | ||
t.end() | ||
}) | ||
!process.browser && tape('test stream', function (t) { | ||
@@ -436,0 +452,0 @@ var random = crypto.randomBytes(65534) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59483
1357