Skip to content

Commit

Permalink
Drop invalid calls to CRYPTO_set_mem_functions
Browse files Browse the repository at this point in the history
These calls did not check the return value. If they had, it would have
shown that the calls were failing due to passing `NULL` for the
`realloc` function pointer. That causes an early return, so the calls
weren't actually doing anything.

The `malloc`/`realloc`/`free` functions defined in
Cryptlib/SysCall/BaseMemAllocation.c are what actually get used, so just
drop the explicit call to `CRYPTO_set_mem_functions`.

Signed-off-by: Nicholas Bishop <[email protected]>
  • Loading branch information
nicholasbishop authored and vathpela committed May 2, 2023
1 parent 1f38cb3 commit 102a658
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1275,24 +1275,10 @@ EFI_STATUS set_second_stage (EFI_HANDLE image_handle)
return EFI_SUCCESS;
}

static void *
ossl_malloc(size_t num)
{
return AllocatePool(num);
}

static void
ossl_free(void *addr)
{
FreePool(addr);
}

static void
init_openssl(void)
{
CRYPTO_set_mem_functions(ossl_malloc, NULL, ossl_free);
OPENSSL_init();
CRYPTO_set_mem_functions(ossl_malloc, NULL, ossl_free);
ERR_load_ERR_strings();
ERR_load_BN_strings();
ERR_load_RSA_strings();
Expand Down

0 comments on commit 102a658

Please sign in to comment.