File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,7 +147,12 @@ DataPointer DataPointer::SecureAlloc(size_t len) {
147147#ifndef OPENSSL_IS_BORINGSSL
148148 auto ptr = OPENSSL_secure_zalloc (len);
149149 if (ptr == nullptr ) return {};
150- return DataPointer (ptr, len, true );
150+ // OPENSSL_secure_zalloc transparently falls back to a regular allocation
151+ // when the secure heap is not initialized or is exhausted. Reflect the
152+ // actual provenance of the pointer so that reset() routes to the correct
153+ // free function (OPENSSL_secure_clear_free vs. OPENSSL_clear_free) and
154+ // callers of isSecure() get a truthful answer.
155+ return DataPointer (ptr, len, CRYPTO_secure_allocated (ptr) == 1 );
151156#else
152157 // BoringSSL does not implement the OPENSSL_secure_zalloc API.
153158 auto ptr = OPENSSL_malloc (len);
Original file line number Diff line number Diff line change @@ -736,7 +736,6 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
736736 uint32_t len = args[0 ].As <Uint32>()->Value ();
737737
738738 auto data = DataPointer::SecureAlloc (len);
739- CHECK (data.isSecure ());
740739 if (!data) {
741740 return THROW_ERR_OPERATION_FAILED (env, " Allocation failed" );
742741 }
You can’t perform that action at this time.
0 commit comments