This repository was archived by the owner on Mar 4, 2020. It is now read-only.
File tree 1 file changed +10
-3
lines changed 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,14 @@ bool EntropySource(unsigned char* buffer, size_t length) {
323
323
}
324
324
325
325
326
+ template <typename T>
327
+ static T* MallocOpenSSL (size_t count) {
328
+ void * mem = OPENSSL_malloc (MultiplyWithOverflowCheck (count, sizeof (T)));
329
+ CHECK_IMPLIES (mem == nullptr , count == 0 );
330
+ return static_cast <T*>(mem);
331
+ }
332
+
333
+
326
334
void SecureContext::Initialize (Environment* env, Local<Object> target) {
327
335
Local<FunctionTemplate> t = env->NewFunctionTemplate (New);
328
336
t->InstanceTemplate ()->SetInternalFieldCount (1 );
@@ -2356,12 +2364,11 @@ int SSLWrap<Base>::TLSExtStatusCallback(SSL* s, void* arg) {
2356
2364
size_t len = Buffer::Length (obj);
2357
2365
2358
2366
// OpenSSL takes control of the pointer after accepting it
2359
- auto * allocator = env->isolate ()->GetArrayBufferAllocator ();
2360
- uint8_t * data = static_cast <uint8_t *>(allocator->AllocateUninitialized (len));
2367
+ unsigned char * data = MallocOpenSSL<unsigned char >(len);
2361
2368
memcpy (data, resp, len);
2362
2369
2363
2370
if (!SSL_set_tlsext_status_ocsp_resp (s, data, len))
2364
- allocator-> Free (data, len );
2371
+ OPENSSL_free (data);
2365
2372
w->ocsp_response_ .Reset ();
2366
2373
2367
2374
return SSL_TLSEXT_ERR_OK;
You can’t perform that action at this time.
0 commit comments