mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 00:20:38 +01:00
Previously, zero-length Buffers and TypedArrays passed as fillers hanged Buffer#fill and Buffer.from. This changes those cases when it hanged to a zero-fill instead, which should be backwards compatible. This fixes CVE-2018-7167. PR-URL: https://github.com/nodejs-private/node-private/pull/119 Fixes: https://github.com/nodejs-private/security/issues/193 Refs: https://github.com/nodejs-private/node-private/pull/118 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
21 lines
412 B
JavaScript
21 lines
412 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
for (const fill of [
|
|
'',
|
|
[],
|
|
Buffer.from(''),
|
|
new Uint8Array(0),
|
|
{ toString: () => '' },
|
|
{ toString: () => '', length: 10 }
|
|
]) {
|
|
for (let i = 0; i < 50; i++) {
|
|
const buf = Buffer.alloc(100, fill);
|
|
assert.strictEqual(buf.length, 100);
|
|
for (let n = 0; n < buf.length; n++)
|
|
assert.strictEqual(buf[n], 0);
|
|
}
|
|
}
|