Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: fix regression on randomFillSync #35723

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/crypto/random.js
Expand Up @@ -113,7 +113,7 @@ function randomFillSync(buf, offset = 0, size) {

const job = new RandomBytesJob(
kCryptoJobSync,
buf.buffer || buf,
buf,
offset,
size);

Expand Down
18 changes: 18 additions & 0 deletions test/parallel/test-crypto-randomfillsync-regression.js
@@ -0,0 +1,18 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const { randomFillSync } = require('crypto');
const { notStrictEqual } = require('assert');

const ab = new ArrayBuffer(20);
const buf = Buffer.from(ab, 10);

const before = buf.toString('hex');

randomFillSync(buf);

const after = buf.toString('hex');

notStrictEqual(before, after);