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

fix: when value is Number,Buffer.alloc replace Buffer.from #719

Merged
merged 1 commit into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"publish-to-cdn": "node publish.js",
"snyk-protect": "snyk protect",
"prepublish": "npm run snyk-protect",
"lint-staged": "lint-staged",
"detect-secrets": "node task/detect-secrets"
},
"git-pre-hooks": {
Expand All @@ -38,7 +39,7 @@
"npm run publish-to-npm",
"npm run publish-to-cdn"
],
"pre-commit": "lint-staged"
"pre-commit": "npm run lint-staged"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions shims/crypto/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var algorithms = {
};

var blocksize = 64;
var zeroBuffer = Buffer.from(blocksize);
var zeroBuffer = Buffer.alloc(blocksize);
zeroBuffer.fill(0);

function hmac(fn, key, data) {
Expand All @@ -24,7 +24,7 @@ function hmac(fn, key, data) {
key = Buffer.concat([key, zeroBuffer], blocksize)
}

var ipad = Buffer.from(blocksize), opad = Buffer.from(blocksize);
var ipad = Buffer.alloc(blocksize), opad = Buffer.alloc(blocksize);
for(var i = 0; i < blocksize; i++) {
ipad[i] = key[i] ^ 0x36
opad[i] = key[i] ^ 0x5C
Expand Down
4 changes: 2 additions & 2 deletions shims/crypto/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var Buffer = require('buffer').Buffer;
var intSize = 4;
var zeroBuffer = Buffer.from(intSize); zeroBuffer.fill(0);
var zeroBuffer = Buffer.alloc(intSize); zeroBuffer.fill(0);
var chrsz = 8;

function toArray(buf, bigEndian) {
Expand All @@ -18,7 +18,7 @@ function toArray(buf, bigEndian) {
}

function toBuffer(arr, size, bigEndian) {
var buf = Buffer.from(size);
var buf = Buffer.alloc(size);
var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
for (var i = 0; i < arr.length; i++) {
fn.call(buf, arr[i], i * 4, true);
Expand Down