Skip to content

Commit

Permalink
Lock volume key structure in memory.
Browse files Browse the repository at this point in the history
This was probably oversight in original commit
introducing support for selective memory locking
on sensitive data only.

Fixes: db65a5c
  • Loading branch information
oniko committed Dec 3, 2024
1 parent ecb1326 commit 1bea029
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/volumekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key)
if (keylength > (SIZE_MAX - sizeof(*vk)))
return NULL;

vk = malloc(sizeof(*vk) + keylength);
vk = crypt_safe_alloc(sizeof(*vk) + keylength);
if (!vk)
return NULL;

Expand Down Expand Up @@ -122,11 +122,9 @@ void crypt_free_volume_key(struct volume_key *vk)
struct volume_key *vk_next;

while (vk) {
crypt_safe_memzero(vk->key, vk->keylength);
vk->keylength = 0;
free(CONST_CAST(void*)vk->key_description);
vk_next = vk->next;
free(vk);
crypt_safe_free(vk);
vk = vk_next;
}
}
Expand Down

0 comments on commit 1bea029

Please sign in to comment.