-
-
Notifications
You must be signed in to change notification settings - Fork 10
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] return valid values on multi-byte-wide TypedArray input #19
base: v3.0
Are you sure you want to change the base?
Conversation
50d3575
to
8640bef
Compare
8640bef
to
48a70d2
Compare
* Makes sense only on engines with full TypedArray support -- let Buffer detect that | ||
*/ | ||
if (useArrayBuffer && ArrayBuffer.isView(data)) { | ||
if (data.byteLength === 0) return Buffer.alloc(0) // Bug in Node.js <6.3.1, which treats this as out-of-bounds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean it breaks in these versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is a fix for those versions
They are only problematic on zero-length arraybuffers, so a check helps
t.test('handle UInt16Array', function (t) { | ||
beforeEach(t, createHashBase) | ||
|
||
if (ArrayBuffer.isView && (Buffer.prototype instanceof Uint8Array || Buffer.TYPED_ARRAY_SUPPORT)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these checks can go in a { skip: } options arg to the test. Often i do { skip: condition && 'explanation' }
and it displays nicely.
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Port of browserify/cipher-base#23 to
hash-base
with minor code cleanupThis technically would have been a Feat, but Node.js handles it, and this module declares support for the same API as Node.js crypto in the readme
So, a Fix
.update
input is converted to Buffer for all supported types and is passed to._update
as a buffer, so this doesn't require any changes in the libraries usinghash-base
to just workChanges an error message but it's also like that in Node.js