Skip to content

Commit

Permalink
Using old pointer after reallocating new buffer
Browse files Browse the repository at this point in the history
Below issue is reported while running TLS1.3:-

p11prov_DeriveKey:Host out of memory

Issue occurs because we are trying to use deallocated memory pointer after
reallocating new memory due to which key->attrs get corrupted and finally
cause issue in importing correct peer key.

Signed-off-by: Kshitiz Varshney <[email protected]>
  • Loading branch information
kshitizvars committed Sep 3, 2024
1 parent 75cc2c3 commit 21d7789
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -2930,8 +2930,8 @@ CK_RV p11prov_obj_set_ec_encoded_public_key(P11PROV_OBJ *key,
}

if (add_attrs > 0) {
void *ptr = OPENSSL_realloc(key->attrs, sizeof(CK_ATTRIBUTE) * (key->numattrs + add_attrs));
if (!ptr) {
key->attrs = OPENSSL_realloc(key->attrs, sizeof(CK_ATTRIBUTE) * (key->numattrs + add_attrs));
if (!key->attrs) {
P11PROV_raise(key->ctx, CKR_HOST_MEMORY,
"Failed to store key public key");
return CKR_HOST_MEMORY;
Expand Down

0 comments on commit 21d7789

Please sign in to comment.