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

iasecc: Avoid memory leaks #2974

Merged
merged 1 commit into from
Jan 10, 2024
Merged

iasecc: Avoid memory leaks #2974

merged 1 commit into from
Jan 10, 2024

Conversation

popovec
Copy link
Member

@popovec popovec commented Jan 7, 2024

@popovec
Copy link
Member Author

popovec commented Jan 7, 2024

When I was looking at the code of the iasecc_delete_file() function, I found one thing, after deleting the file using SM, it does not update card->cache.current_ef. Can someone who knows details about the "iaescc" code confirm whether the following patch should be applied?

index b20123d65..7ec1fd575 100644
--- a/src/libopensc/card-iasecc.c
+++ b/src/libopensc/card-iasecc.c
@@ -1573,13 +1573,11 @@ iasecc_delete_file(struct sc_card *card, const struct sc_path *path)
                rv = sc_transmit_apdu(card, &apdu);
                LOG_TEST_RET(ctx, rv, "APDU transmit failed");
                rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-               LOG_TEST_RET(ctx, rv, "Delete file failed");
-
-               if (card->cache.valid) {
-                       sc_file_free(card->cache.current_ef);
-               }
-               card->cache.current_ef = NULL;
        }
+       LOG_TEST_RET(ctx, rv, "Delete file failed");
+       if (card->cache.valid)
+               sc_file_free(card->cache.current_ef);
+       card->cache.current_ef = NULL;
 
        LOG_FUNC_RETURN(ctx, rv);
 }

@Jakuje
Copy link
Member

Jakuje commented Jan 8, 2024

When I was looking at the code of the iasecc_delete_file() function, I found one thing, after deleting the file using SM, it does not update card->cache.current_ef. Can someone who knows details about the "iaescc" code confirm whether the following patch should be applied?

I would say yes, but I am not that much familiar with the iasecc. Maybe @vjardin ?

@vjardin
Copy link
Contributor

vjardin commented Jan 8, 2024

I would say yes, but I am not that much familiar with the iasecc. Maybe @vjardin ?

I would need to run some tests with some IASECC cards, but I do not have time for some short terms ; can it wait a bit ?

@popovec
Copy link
Member Author

popovec commented Jan 8, 2024

Feel free to find time to test it, it's not urgent. It can be fixed in another PR.

@frankmorgner
Copy link
Member

some of the functionality around current_ef/df has been removed in the last releases, because it was breaking use cases with concurrent access to the card. Also, speedup was very limited with respect to the complexity added. In the iasecc driver the handling of current_ef/df has not been removed, because it is deeply woven into the driver. Feel free to simplify that...

@Jakuje
Copy link
Member

Jakuje commented Jan 10, 2024

Thank you! Merging to move on with fuzzing. @popovec Please move the discussion regarding to the delete file either to new issue or draft PR so it wont get lost.

@Jakuje Jakuje merged commit 773fcc6 into OpenSC:master Jan 10, 2024
36 checks passed
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.

None yet

4 participants