https://github.com/python/cpython/commit/e1320ae4c3c53e09108f2089fecab545def44d23 commit: e1320ae4c3c53e09108f2089fecab545def44d23 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: picnixz <[email protected]> date: 2026-07-04T10:41:40Z summary:
[3.15] gh-152851: fix a crash when copying a BLAKE-2s/2b object (GH-153008) (#153011) gh-152851: fix a crash when copying a BLAKE-2s/2b object (GH-153008) (cherry picked from commit 5a400ceafbbd4456ac65fbdbcf5d62ce9e8e4f9f) Co-authored-by: Bénédikt Tran <[email protected]> files: A Misc/NEWS.d/next/Library/2026-07-04-11-14-06.gh-issue-152851.diYvTf.rst M Modules/blake2module.c diff --git a/Misc/NEWS.d/next/Library/2026-07-04-11-14-06.gh-issue-152851.diYvTf.rst b/Misc/NEWS.d/next/Library/2026-07-04-11-14-06.gh-issue-152851.diYvTf.rst new file mode 100644 index 00000000000000..aab033ebeed695 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-04-11-14-06.gh-issue-152851.diYvTf.rst @@ -0,0 +1,2 @@ +Prevent a crash when allocation fails while copying a :func:`BLAKE-2s/2b +<hashlib.blake2b>` object. Patch by Bénédikt Tran. diff --git a/Modules/blake2module.c b/Modules/blake2module.c index b71dd20925611e..ac7265bb9d6836 100644 --- a/Modules/blake2module.c +++ b/Modules/blake2module.c @@ -757,6 +757,10 @@ blake2_blake2b_copy_unlocked(Blake2Object *self, Blake2Object *cpy) } \ } while (0) + // Ensure that the implementation type is consistent with the HACL* state. + // See https://github.com/python/cpython/issues/152851 for details. + cpy->impl = self->impl; + switch (self->impl) { #if _Py_HACL_CAN_COMPILE_VEC256 case Blake2b_256: @@ -778,7 +782,6 @@ blake2_blake2b_copy_unlocked(Blake2Object *self, Blake2Object *cpy) Py_UNREACHABLE(); } #undef BLAKE2_COPY - cpy->impl = self->impl; return 0; error: _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
