]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-125118: don't copy arbitrary values to _Bool in the struct module (GH-125169)
authorSergey B Kirpichev <skirpichev@gmail.com>
Thu, 10 Oct 2024 12:42:03 +0000 (15:42 +0300)
committerGitHub <noreply@github.com>
Thu, 10 Oct 2024 12:42:03 +0000 (14:42 +0200)
commit87d7315ac57250046372b0d9ae4619ba619c8c87
tree3faebb9b68976d101e1f0433f4c8eb1e3e65c4b1
parente4cab488d4445e8444932f3bed1c329c0d9e5038
gh-125118: don't copy arbitrary values to _Bool in the struct module (GH-125169)

memcopy'ing arbitrary values to _Bool variable triggers undefined
behaviour. Avoid this.
We assume that `false` is represented by all zero bytes.

Credits to Alex Gaynor.

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Lib/test/test_struct.py
Misc/NEWS.d/next/Library/2024-10-09-07-09-00.gh-issue-125118.J9rQ1S.rst [new file with mode: 0644]
Modules/_struct.c