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

node 0.10, more checks for keylen #27

Merged
merged 3 commits into from
Mar 8, 2016

Conversation

fanatid
Copy link
Contributor

@fanatid fanatid commented Mar 6, 2016

Another attempt (summary of #22 #23 #25 #26)

@dcousens
Copy link
Member

dcousens commented Mar 7, 2016

I haven't got time to merge this at the moment. Once-over looks good.
ping @calvinmetcalf

@calvinmetcalf
Copy link
Contributor

this does much more then simply update the keylen checks, can you add some comments in the pull to make it easeir to review the changes ?

@fanatid
Copy link
Contributor Author

fanatid commented Mar 7, 2016

  • index.js is more clean now, when node v0.10 supports will be finished (01.2017?) it will be easy update this package
  • browser.js additionally exports _checkParameters and _createHmac (it's done for node v0.10), by default _createHmac uses pure js hmac (but node-shim.js update _createHmac for using crypto.createHmac)

@calvinmetcalf if you have any questions, please ask!

@@ -34,20 +14,33 @@ function checkParameters (iterations, keylen) {
throw new TypeError('Key length not a number')
}

if (keylen < 0 || keylen > MAX_ALLOC) {
if (keylen < 0 || isNaN(keylen) || keylen > MAX_ALLOC) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want to do keylen !== keylen as older browsers aren't going to have isNaN

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in lodash isNaN: value != +value
https://github.com/lodash/lodash/blob/092f90d2fca959fa75d14cae8a2377a58bcb122d/lodash.js#L10534
or better will use keylen !== keylen ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lodash is making sure it's a number, but we already have a check to do that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


digest = digest || 'sha1'
exports._checkParameters(iterations, keylen)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we pull check paramaters into it's own file and require it from both locations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a good idea, I'll do this

@calvinmetcalf
Copy link
Contributor

get rid of the browser._createHmac stuff and fix the typo and I'm good to merge this thank you for the work

@fanatid fanatid force-pushed the feature/node-shim branch 2 times, most recently from 4c71354 to b080e6e Compare March 8, 2016 12:58
@fanatid
Copy link
Contributor Author

fanatid commented Mar 8, 2016

@calvinmetcalf done. Thank you that checked this!

@fanatid
Copy link
Contributor Author

fanatid commented Mar 8, 2016

Please rename async-shim.js to node-shim-async.js after merge.

@calvinmetcalf calvinmetcalf merged commit 93ffd51 into browserify:master Mar 8, 2016
@fanatid fanatid deleted the feature/node-shim branch March 8, 2016 17:06
@fanatid fanatid mentioned this pull request Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants