Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-130151: Fix reference leaks in_hashlib.hmac_{new,digest}#130152
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
6d84554 toc9d0c0dCompareencukou commentedFeb 18, 2025
Thanks, good catch! Why reorganize the code, though? AFAICS, declaring pointers at the top and setting them to Not sure about the change from |
picnixz commentedFeb 21, 2025
I think it's to align with other instances of similar code. In other cases I think we raise a MemoryError. But I need to check it.
I think the impl comment would be implicit but it's my IDE, I'll restore it. As for
For me it was more an ANSI C approach where all variables are declared at the top of the function. However since I felt it was cleaner like this. But I can revert it and make it ANSI C. |
picnixz commentedFeb 22, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Concerning Note that we also return NULL if the context cannot be reset correctly, but this only means that one the underlying EVP contexts couldn't be allocated either:https://github.com/openssl/openssl/blob/0bdd10e4078beccaa49ea015b6660f3facfab02b/crypto/hmac/hmac.c#L198 andhttps://github.com/openssl/openssl/blob/0bdd10e4078beccaa49ea015b6660f3facfab02b/crypto/evp/digest.c#L129. So the NULL should only be returned by EDIT: This is assuming we are using |
Uh oh!
There was an error while loading.Please reload this page.
0718201 intopython:mainUh oh!
There was an error while loading.Please reload this page.
…ythonGH-130152)* fix leak in `_hashlib.hmac_new`* fix leak in `hmac_digest`* fix exception type in `_hashlib.HMAC.copy`(cherry picked from commit0718201)Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
GH-130491 is a backport of this pull request to the3.13 branch. |
Sorry,@picnixz and@gpshead, I could not cleanly backport this to |
picnixz commentedFeb 24, 2025
I'll take care of the bp tomorrow (it's 1 AM here) if no one is doing it |
…GH-130152) (#130491)gh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152)* fix leak in `_hashlib.hmac_new`* fix leak in `hmac_digest`* fix exception type in `_hashlib.HMAC.copy`(cherry picked from commit0718201)Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz commentedFeb 24, 2025
Huh, I forgot. I didn't have time this morning. I'll do it... well, either this night or tomorrow. Sorry :( |
GH-130539 is a backport of this pull request to the3.12 branch. |
…GH-130152) (#130539)gh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152)* fix leak in `_hashlib.hmac_new`* fix leak in `hmac_digest`* fix exception type in `_hashlib.HMAC.copy`(cherry picked from commit0718201)
Uh oh!
There was an error while loading.Please reload this page.
_hashlib.hmac_newand_hashlib.hmac_digest#130151