Skip to content

Commit

Permalink
Removes uses of OPENSSL_malloc
Browse files Browse the repository at this point in the history
since it is simply a macro that adds debug info __FUNC__ and
__LINE__ to a normal malloc() call.
The code now use malloc throughout.
  • Loading branch information
bjornvolcker committed Mar 22, 2024
1 parent d332069 commit 32a94c8
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/plugins/threaded-signing/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ signature_info_create(const signature_info_t *signature_info)

if (signature_info->max_signature_size) {
// Allocate memory for the |signature|.
tmp_signature_info->signature = openssl_malloc(signature_info->max_signature_size);
tmp_signature_info->signature = malloc(signature_info->max_signature_size);
if (!tmp_signature_info->signature) goto catch_error;
tmp_signature_info->max_signature_size = signature_info->max_signature_size;
} else {
Expand Down Expand Up @@ -883,7 +883,7 @@ sv_interface_teardown(void *plugin_handle)
uint8_t *
sv_interface_malloc(size_t data_size)
{
return openssl_malloc(data_size);
return malloc(data_size);
}

/* TO BE DEPRECATED */
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/unthreaded-signing/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ sv_interface_teardown(void *plugin_handle)
uint8_t *
sv_interface_malloc(size_t data_size)
{
return openssl_malloc(data_size);
return malloc(data_size);
}

void
Expand Down
12 changes: 0 additions & 12 deletions lib/src/includes/signed_video_openssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ openssl_create_handle(void);
void
openssl_free_handle(void *handle);

/**
* @brief Malloc data
*
* Allocates the memory for data.
*
* @param size Data size.
*
* @returns Pointer to allocated memory.
*/
uint8_t *
openssl_malloc(size_t size);

/**
* @brief Frees data
*
Expand Down
2 changes: 1 addition & 1 deletion lib/src/signed_video_h26x_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ generate_sei_nalu(signed_video_t *self, uint8_t **payload, uint8_t **payload_sig

signature_info->signature_size = 0;
signature_info->max_signature_size = 0;
signature_info->signature = sv_interface_malloc(max_signature_size);
signature_info->signature = malloc(max_signature_size);
SVI_THROW_IF(!signature_info->signature, SVI_MEMORY);
signature_info->max_signature_size = max_signature_size;
}
Expand Down
9 changes: 1 addition & 8 deletions lib/src/signed_video_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ openssl_create_private_key(sign_algo_t algo, const char *path_to_key, key_paths_
#define PRIVATE_RSA_KEY_FILE "private_rsa_key.pem"
#define PRIVATE_ECDSA_KEY_FILE "private_ecdsa_key.pem"

/* Allocate data using OpenSSL API. */
uint8_t *
openssl_malloc(size_t size)
{
return OPENSSL_malloc(size);
}

/* Free the data allocated by OpenSSL. */
void
openssl_free(uint8_t *data)
Expand Down Expand Up @@ -127,7 +120,7 @@ openssl_signature_malloc(signature_info_t *signature_info)
size_t max_signature_size = EVP_PKEY_size(signing_key);
EVP_PKEY_free(signing_key);
SVI_THROW_IF(max_signature_size == 0, SVI_EXTERNAL_FAILURE);
signature_info->signature = openssl_malloc(max_signature_size);
signature_info->signature = malloc(max_signature_size);
SVI_THROW_IF(!signature_info->signature, SVI_MEMORY);
signature_info->max_signature_size = max_signature_size;
SVI_CATCH()
Expand Down
2 changes: 1 addition & 1 deletion lib/src/signed_video_tlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ decode_signature(signed_video_t *self, const uint8_t *data, size_t data_size)
signature_info->max_signature_size = 0;
signature_info->signature_size = 0;
// Allocate enough space for future signatures as well, that is, max_signature_size.
*signature_ptr = sv_interface_malloc(max_signature_size);
*signature_ptr = malloc(max_signature_size);
SVI_THROW_IF(!*signature_ptr, SVI_MEMORY);
// Set memory size.
signature_info->max_signature_size = max_signature_size;
Expand Down

0 comments on commit 32a94c8

Please sign in to comment.