Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd84af7

Browse filesBrowse files
mertcanaltinaduh95
authored andcommitted
src: handle null backing store in ArrayBufferViewContents::Read
Fixes: #62342 src: handle null backing store in ArrayBufferViewContents::Read PR-URL: #62343 Fixes: #62342 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent a416ddf commit cd84af7
Copy full SHA for cd84af7

2 files changed

+26-1Lines changed: 26 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/util-inl.h‎

Copy file name to clipboardExpand all lines: src/util-inl.h
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,9 @@ void ArrayBufferViewContents<T, S>::Read(v8::Local<v8::ArrayBufferView> abv) {
591591
static_assert(sizeof(T) == 1, "Only supports one-byte data at the moment");
592592
length_ = abv->ByteLength();
593593
if (length_ > sizeof(stack_storage_) || abv->HasBuffer()) {
594-
data_ = static_cast<T*>(abv->Buffer()->Data()) + abv->ByteOffset();
594+
auto buf_data = abv->Buffer()->Data();
595+
data_ = buf_data != nullptr ? static_cast<T*>(buf_data) + abv->ByteOffset()
596+
: stack_storage_;
595597
} else {
596598
abv->CopyContents(stack_storage_, sizeof(stack_storage_));
597599
data_ = stack_storage_;
Collapse file

‎test/parallel/test-crypto-authenticated.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-authenticated.js
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,3 +772,26 @@ for (const test of TEST_CASES) {
772772
decipher.final();
773773
}, /Unsupported state or unable to authenticate data/);
774774
}
775+
776+
// Refs: https://github.com/nodejs/node/issues/62342
777+
{
778+
const key = crypto.randomBytes(16);
779+
const nonce = crypto.randomBytes(13);
780+
781+
const cipher = crypto.createCipheriv('aes-128-ccm', key, nonce, {
782+
authTagLength: 16,
783+
});
784+
cipher.setAAD(Buffer.alloc(0), { plaintextLength: 0 });
785+
cipher.update(new DataView(new ArrayBuffer(0)));
786+
cipher.final();
787+
const tag = cipher.getAuthTag();
788+
assert.strictEqual(tag.length, 16);
789+
790+
const decipher = crypto.createDecipheriv('aes-128-ccm', key, nonce, {
791+
authTagLength: 16,
792+
});
793+
decipher.setAuthTag(tag);
794+
decipher.setAAD(Buffer.alloc(0), { plaintextLength: 0 });
795+
decipher.update(new DataView(new ArrayBuffer(0)));
796+
decipher.final();
797+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.