Skip to content

Commit 2ee0b88

Browse files
chore: sync ncrypto from Node.js v26.1.0 (#46)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Filip Skokan <panva.ip@gmail.com>
1 parent a35fdba commit 2ee0b88

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

.github/sync-node-ncrypto.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"node_commit": "8385efc01343a835e3a0efe05611f44272cbb413"
2+
"node_commit": "e7da6f056ac4afeaaf012042188818ca7736f437"
33
}

src/ncrypto.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ DataPointer DataPointer::SecureAlloc(size_t len) {
156156
#ifndef OPENSSL_IS_BORINGSSL
157157
auto ptr = OPENSSL_secure_zalloc(len);
158158
if (ptr == nullptr) return {};
159-
return DataPointer(ptr, len, true);
159+
// OPENSSL_secure_zalloc transparently falls back to a regular allocation
160+
// when the secure heap is not initialized or is exhausted. Reflect the
161+
// actual provenance of the pointer so that reset() routes to the correct
162+
// free function (OPENSSL_secure_clear_free vs. OPENSSL_clear_free) and
163+
// callers of isSecure() get a truthful answer.
164+
return DataPointer(ptr, len, CRYPTO_secure_allocated(ptr) == 1);
160165
#else
161166
// BoringSSL does not implement the OPENSSL_secure_zalloc API.
162167
auto ptr = OPENSSL_malloc(len);

0 commit comments

Comments
 (0)