Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change/check free(pointer) pattern #189

Closed
dccutrig opened this issue Jul 20, 2023 · 5 comments · Fixed by #193
Closed

Change/check free(pointer) pattern #189

dccutrig opened this issue Jul 20, 2023 · 5 comments · Fixed by #193
Assignees
Labels
bug Something isn't working cmp NASA GSFC CMP kmc NASA JPL KMC

Comments

@dccutrig
Copy link
Contributor

e.g. instead of free(aad) look at if(!aad) free(aad);

Identified a possible issue in TC_Apply if using an AEAD algorithm for encryption only. Need to assess further, deals with AAD not being generated for encryption only, but being freed in error cases.

@dccutrig dccutrig added the bug Something isn't working label Jul 20, 2023
@jlucas9
Copy link
Collaborator

jlucas9 commented Jul 21, 2023

I think we may just want to #define the maximum length for all fields and have them declared instead of mallocing / freeing anywhere if possible.

@jlucas9 jlucas9 self-assigned this Jul 21, 2023
@dccutrig
Copy link
Contributor Author

We could, but there was a lot of byte math that would need re-worked to support this. Particularly (If i recall) in the interactio nand ordering of byte fields sent back and forth to KMC.

@dccutrig dccutrig linked a pull request Jul 26, 2023 that will close this issue
@dccutrig dccutrig self-assigned this Jul 26, 2023
@dccutrig
Copy link
Contributor Author

Robert and I walked through the GSFC setup and determined that the logic for what they were trying to do exists, seems it was just a config issue.

@jlucas9
Copy link
Collaborator

jlucas9 commented Jul 27, 2023

Fix merged into dev already and applied to a new kmc branch for continued NASA JPL testing.

@jlucas9 jlucas9 closed this as completed Jul 27, 2023
@jlucas9 jlucas9 added kmc NASA JPL KMC cmp NASA GSFC CMP labels Jul 27, 2023
@spicydll
Copy link

This is an anti-pattern and introduces memory leaks. free() does nothing if it is passed a null pointer. What this pattern does is only free pointers if they are null, and therefore already failed to allocate. Therefore, any successfully allocated heap pointer will never be free'd when using this pattern. I highly recommend you revert this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cmp NASA GSFC CMP kmc NASA JPL KMC
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants