FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-93964: Harden overflow checks before _PyBytes_Resize in compile.c by sweeneyde · Pull Request #94044 · python/cpython · GitHub

/ cpython Public

GH-93964: Harden overflow checks before _PyBytes_Resize in compile.c - #94044

Open
sweeneyde wants to merge 8 commits into
python:mainfrom
sweeneyde:compile_overflows
Open

GH-93964: Harden overflow checks before _PyBytes_Resize in compile.c#94044
sweeneyde wants to merge 8 commits into
python:mainfrom
sweeneyde:compile_overflows

Conversation

sweeneyde commented Jun 21, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

#93964

The issue was found in 3.10, so it will need to be manually backported there.

sweeneyde marked this pull request as draft June 21, 2022 03:43
sweeneyde marked this pull request as ready for review June 21, 2022 04:48
sweeneyde added the needs backport to 3.11 only security fixes label Jun 21, 2022
Comment thread Python/compile.c Outdated
Py_ssize_t b_len = PyBytes_GET_SIZE(*bytes);
if (unitsize * logical_length >= b_len - to_add * unitsize) {
// There's not enough room. Double it.
if (b_len > PY_SSIZE_T_MAX / 2) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This has the same issue as the backport.
We want to be able to index all code object structures with an int, so you'll need INT_MAX instead of PY_SSIZE_T_MAX and it should be an overflow error, not a memory error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

To clarify, we want a_bytecode to be able to have INT_MAX code units, not just INT_MAX bytes, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We probably want the smaller amount to avoid risk of overflow. So the length in bytes should be less than INT_MAX.

Copy link
Copy Markdown
Member

Is the PR still relevant or some other PR superseded this one?

For merge conflict resolution: touched functions were moved to Python/assemble.c by gh-103277.

cc @iritkatriel

serhiy-storchaka added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes and removed needs backport to 3.11 only security fixes labels May 9, 2024
serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label May 8, 2025
ZeroIntensity removed the needs backport to 3.12 only security fixes label May 29, 2025

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 11, 2026
serhiy-storchaka added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 30, 2026
github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL