This is applicable to v4.x only. Native Fill method is called from Buffer.alloc and from Buffer#fill, the second one is not affected by this, as Buffer#fill only calls the native method on either numbers as the second argument or non-zero-length strings. Fixes: https://github.com/nodejs-private/security/issues/192 PR-URL: https://github.com/nodejs-private/node-private/pull/118 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
20 lines
412 B
JavaScript
20 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);
|
|
}
|
|
}
|