-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6d84554
to
c9d0c0d
Compare
Thanks, good catch! Why reorganize the code, though? AFAICS, declaring pointers at the top and setting them to Not sure about the change from |
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 |
…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 <[email protected]>
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
|
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 <[email protected]>
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)
…ythonGH-130152) * fix leak in `_hashlib.hmac_new` * fix leak in `hmac_digest` * fix exception type in `_hashlib.HMAC.copy`
_hashlib.hmac_new
and_hashlib.hmac_digest
#130151