Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-101178: Fix possible integer overflow in Ascii85 encoder with wrapcol=1#144778

Merged
serhiy-storchaka merged 1 commit into
python:mainpython/cpython:mainfrom
serhiy-storchaka:ascii85-encode-integer-overflowserhiy-storchaka/cpython:ascii85-encode-integer-overflowCopy head branch name to clipboard
Feb 24, 2026
Merged

gh-101178: Fix possible integer overflow in Ascii85 encoder with wrapcol=1#144778
serhiy-storchaka merged 1 commit into
python:mainpython/cpython:mainfrom
serhiy-storchaka:ascii85-encode-integer-overflowserhiy-storchaka/cpython:ascii85-encode-integer-overflowCopy head branch name to clipboard

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Feb 13, 2026

Copy link
Copy Markdown
Member

It could happen if the size of the input is more than 4/5 of sys.maxsize (only feasible on 32-bit platforms).

Also simplify the integer overflow checks in the Base64 encoder, and harmonize them with the code for Ascii85 and Base85.

…h wrapcol=1

It could happen if the size of the input is more than 4/5 of sys.maxsize
(only feasible on 32-bit platforms).

Also simplify the integer overflow checks in the Base64 encoder, and
harmonize them with the code for Ascii85 and Base85.
Comment thread Modules/binascii.c
out_len -= 4 - (bin_len % 4);
}
if (wrapcol && out_len) {
if (wrapcol && out_len && out_len <= PY_SSIZE_T_MAX) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let me know if I'm misunderstanding, but wouldn't we need to "error out" if the out_len would overflow here instead of not expanding? The larger amount of data will still be written outside ascii_data whether out_len is expanded or not?

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.

We error out in the next "if".

@serhiy-storchaka serhiy-storchaka merged commit b32c830 into python:main Feb 24, 2026
86 of 87 checks passed
@serhiy-storchaka serhiy-storchaka deleted the ascii85-encode-integer-overflow branch February 24, 2026 09:40
brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
…h wrapcol=1 (pythonGH-144778)

It could happen if the size of the input is more than 4/5 of sys.maxsize
(only feasible on 32-bit platforms).

Also simplify the integer overflow checks in the Base64 encoder, and
harmonize them with the code for Ascii85 and Base85.
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
…h wrapcol=1 (pythonGH-144778)

It could happen if the size of the input is more than 4/5 of sys.maxsize
(only feasible on 32-bit platforms).

Also simplify the integer overflow checks in the Base64 encoder, and
harmonize them with the code for Ascii85 and Base85.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.