Uh oh!
There was an error while loading. Please reload this page.
gh-130151: Fix reference leaks in _hashlib.hmac_{new,digest} - #130152
Conversation
6d84554 to
c9d0c0dCompareencukou
commented
Feb 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
commented
Feb 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. |
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 and https://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.
…ythonGH-130152) * fix leak in `_hashlib.hmac_new` * fix leak in `hmac_digest` * fix exception type in `_hashlib.HMAC.copy` (cherry picked from commit 0718201) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
GH-130491 is a backport of this pull request to the 3.13 branch. |
Sorry, @picnixz and @gpshead, I could not cleanly backport this to |
picnixz
commented
Feb 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 commit 0718201) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz
commented
Feb 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 the 3.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 commit 0718201)
_hashlib.hmac_newand_hashlib.hmac_digest#130151