Skip to content
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

gh-124248: Fix crash in struct when processing 0p fields #124251

Merged
merged 5 commits into from
Sep 20, 2024

Conversation

brianschubert
Copy link
Contributor

Fixes gh-124248.

Adds special handling for the case when code->size is 0 before attempting to decrement code->size or read the first byte under res.

After this change, 0p should behave like 0s.

Modules/_struct.c Outdated Show resolved Hide resolved
Modules/_struct.c Outdated Show resolved Hide resolved
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner vstinner added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Sep 20, 2024
@vstinner vstinner merged commit 63f1960 into python:main Sep 20, 2024
41 checks passed
@miss-islington-app
Copy link

Thanks @brianschubert for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 20, 2024
…nGH-124251)

(cherry picked from commit 63f1960)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Sep 20, 2024

GH-124277 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 20, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 20, 2024
…nGH-124251)

(cherry picked from commit 63f1960)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Sep 20, 2024

GH-124278 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Sep 20, 2024
@vstinner
Copy link
Member

Merged, thanks for the bug report and the fix!

vstinner pushed a commit that referenced this pull request Sep 20, 2024
…24251) (#124278)

gh-124248: Fix crash in struct when processing 0p fields (GH-124251)
(cherry picked from commit 63f1960)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
savannahostrowski pushed a commit to savannahostrowski/cpython that referenced this pull request Sep 22, 2024
savannahostrowski pushed a commit to savannahostrowski/cpython that referenced this pull request Sep 22, 2024
Yhg1s pushed a commit that referenced this pull request Sep 30, 2024
…24251) (#124277)

gh-124248: Fix crash in struct when processing 0p fields (GH-124251)
(cherry picked from commit 63f1960)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SystemError/Assertion failure when processing struct with '0p' field
3 participants