Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/sync-node-ncrypto.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"node_commit": "8385efc01343a835e3a0efe05611f44272cbb413"
"node_commit": "25f80fb7647d2c22b26359f4a5945a8c2b7efff3"
}
7 changes: 6 additions & 1 deletion src/ncrypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ DataPointer DataPointer::SecureAlloc(size_t len) {
#ifndef OPENSSL_IS_BORINGSSL
auto ptr = OPENSSL_secure_zalloc(len);
if (ptr == nullptr) return {};
return DataPointer(ptr, len, true);
// OPENSSL_secure_zalloc transparently falls back to a regular allocation
// when the secure heap is not initialized or is exhausted. Reflect the
// actual provenance of the pointer so that reset() routes to the correct
// free function (OPENSSL_secure_clear_free vs. OPENSSL_clear_free) and
// callers of isSecure() get a truthful answer.
return DataPointer(ptr, len, CRYPTO_secure_allocated(ptr) == 1);
#else
// BoringSSL does not implement the OPENSSL_secure_zalloc API.
auto ptr = OPENSSL_malloc(len);
Expand Down
Loading