-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Improve error-branches of hashlib
#127667
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
Labels
3.12
only security fixes
3.13
bugs and security fixes
3.14
bugs and security fixes
extension-modules
C modules in the Modules dir
type-bug
An unexpected behavior, bug, or error
Comments
hashlib
hashlib
picnixz
added a commit
that referenced
this issue
Mar 3, 2025
- Correctly handle `NULL` values returned by `EVP_MD_CTX_md`. - Correctly free resources in error branches. - Consistently suppress `_setException()` return value when needed. - Collapse `_setException() + return NULL` into a single statement.
picnixz
added a commit
to picnixz/cpython
that referenced
this issue
Mar 3, 2025
- Correctly handle `NULL` values returned by `EVP_MD_CTX_md`. - Correctly free resources in error branches. - Consistently suppress `_setException()` return value when needed. - Collapse `_setException() + return NULL` into a single statement.
picnixz
added a commit
to picnixz/cpython
that referenced
this issue
Mar 3, 2025
- Correctly handle `NULL` values returned by `EVP_MD_CTX_md`. - Correctly free resources in error branches. - Consistently suppress `_setException()` return value when needed. - Collapse `_setException() + return NULL` into a single statement.
picnixz
added a commit
that referenced
this issue
Mar 3, 2025
gh-127667: fix memory leaks in `hashlib` (GH-127668) - Correctly handle `NULL` values returned by `EVP_MD_CTX_md`. - Correctly free resources in error branches. - Consistently suppress `_setException()` return value when needed. - Collapse `_setException() + return NULL` into a single statement. (cherry-picked from commit 0978465)
picnixz
added a commit
that referenced
this issue
Mar 3, 2025
gh-127667: fix memory leaks in `hashlib` (GH-127668) - Correctly handle `NULL` values returned by `EVP_MD_CTX_md`. - Correctly free resources in error branches. - Consistently suppress `_setException()` return value when needed. - Collapse `_setException() + return NULL` into a single statement. (cherry-picked from commit 0978465)
picnixz
added a commit
that referenced
this issue
Mar 17, 2025
) Refactor `_setException()` into different helpers that can be used separately: - set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code. - raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message. - notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.
picnixz
added a commit
to picnixz/cpython
that referenced
this issue
Mar 17, 2025
…python#131145) Refactor `_setException()` into different helpers that can be used separately: - set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code. - raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message. - notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.
picnixz
added a commit
to picnixz/cpython
that referenced
this issue
Mar 17, 2025
…python#131145) Refactor `_setException()` into different helpers that can be used separately: - set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code. - raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message. - notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message. # Conflicts: # Modules/_hashopenssl.c
plashchynski
pushed a commit
to plashchynski/cpython
that referenced
this issue
Mar 17, 2025
…python#131145) Refactor `_setException()` into different helpers that can be used separately: - set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code. - raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message. - notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.
picnixz
added a commit
that referenced
this issue
Mar 18, 2025
#131145) (#131348) gh-127667: refactor and improve `_hashopenssl.c` error branches (#131145) Refactor `_setException()` into different helpers that can be used separately: - set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code. - raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message. - notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message. (cherry-picked from commit ac50ece).
picnixz
added a commit
that referenced
this issue
Mar 18, 2025
#131145) (#131347) gh-127667: refactor and improve `_hashopenssl.c` error branches (#131145) Refactor `_setException()` into different helpers that can be used separately: - set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code. - raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message. - notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message. (cherry-picked from commit ac50ece).
seehwan
pushed a commit
to seehwan/cpython
that referenced
this issue
Apr 16, 2025
- Correctly handle `NULL` values returned by `EVP_MD_CTX_md`. - Correctly free resources in error branches. - Consistently suppress `_setException()` return value when needed. - Collapse `_setException() + return NULL` into a single statement.
seehwan
pushed a commit
to seehwan/cpython
that referenced
this issue
Apr 16, 2025
…python#131145) Refactor `_setException()` into different helpers that can be used separately: - set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code. - raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message. - notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.12
only security fixes
3.13
bugs and security fixes
3.14
bugs and security fixes
extension-modules
C modules in the Modules dir
type-bug
An unexpected behavior, bug, or error
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
While reading the hashlib code, I found some issues in the error branches where the
EVP_MD_ctx
is not freed upon failure or when we callpy_digest_name
with a NULLEVP_MD *
.@gpshead Should I consider this as a security issue? (some places might be a security issue since we are leaking some EVP_MD context objects but others are just leaking un-initialized contexts).
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
hashlib
#127668hashlib
(GH-127668) #130783hashlib
(GH-127668) #130784_hashopenssl.c
error branches #131145_hashopenssl.c
error branches (#131145) #131347_hashopenssl.c
error branches (#131145) #131348The text was updated successfully, but these errors were encountered: