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 8d0c22e

Browse filesBrowse files
ndosscheaduh95
authored andcommitted
crypto: fix potential null pointer dereference when BIO_meth_new() fails
This function can return null, which will make the calls to BIO_meth_set_* trigger a null deref. Even after fixing this, there is an issue with the `BIOPointer::New(GetMethod())` call in `NodeBIO::New` because the `New` method cannot handle a null pointer despite other code already guarding for this (e.g. the `NodeBIO::New` function already checks `bio`). This patch solves the issues by adding more null checks. PR-URL: #61788 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 78fa1a1 commit 8d0c22e
Copy full SHA for 8d0c22e

2 files changed

+2Lines changed: 2 additions & 0 deletions

File tree

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

‎deps/ncrypto/ncrypto.cc‎

Copy file name to clipboardExpand all lines: deps/ncrypto/ncrypto.cc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,7 @@ BIOPointer BIOPointer::NewSecMem() {
14701470
}
14711471

14721472
BIOPointer BIOPointer::New(const BIO_METHOD* method) {
1473+
if (method == nullptr) return {};
14731474
return BIOPointer(BIO_new(method));
14741475
}
14751476

Collapse file

‎src/crypto/crypto_bio.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_bio.cc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ const BIO_METHOD* NodeBIO::GetMethod() {
226226
// Static initialization ensures that this is safe to use concurrently.
227227
static const BIO_METHOD* method = [&]() {
228228
BIO_METHOD* method = BIO_meth_new(BIO_TYPE_MEM, "node.js SSL buffer");
229+
CHECK_NOT_NULL(method);
229230
BIO_meth_set_write(method, Write);
230231
BIO_meth_set_read(method, Read);
231232
BIO_meth_set_puts(method, Puts);

0 commit comments

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