Skip to content

Fix memory leaks#33

Open
stefanberger wants to merge 2 commits intolinux-integrity:next-testingfrom
stefanberger:fix-memory-leak
Open

Fix memory leaks#33
stefanberger wants to merge 2 commits intolinux-integrity:next-testingfrom
stefanberger:fix-memory-leak

Conversation

@stefanberger
Copy link
Copy Markdown
Contributor

This PR fixes two memory leaks in the library. Both leaks were found using the sign_verify test:

CFLAGS="-fsanitize=address,undefined -g -fno-omit-frame-pointer -fno-sanitize-recover" LIBS="-lasan -lubsan" ./configure --prefix=/usr
make install
./tests/sign_verify.test

Use EVP_PKEY_free to fix a memory leak that occurs when using free() on the
key field of public_key_entry that is a pointer to an EVP_PKEY.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Avoid a memory leak of a public_key_entry if the passed public_keys
pointer is NULL because in this case the entry is lost. For this particular
case to work we would need public keys to be passed in as
'struct public_key_entry **public_keys' so that '*public_keys = entry'
could be assign. However, this change would propagate all the way to the
API of the library and we don't want to change existing functions'
signature.

This change should not have any noticeable side-effect since the resolved
case did not work before but the newly allocated entry was lost.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant