Skip to content

bpo-36946:Fix possible signed integer overflow when handling slices #15639

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

Conversation

hongweipeng
Copy link
Contributor

@hongweipeng hongweipeng commented Sep 2, 2019

This is a complement to that PR #13375 .

https://bugs.python.org/issue36946

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

There is a similar issue in list_ass_subscript. Could you pleas check and fix all other occurrences of cur +=?

@hongweipeng hongweipeng changed the title bpo-36946:A complement to fix possible signed integer overflow when handling sl… bpo-36946:Fix possible signed integer overflow when handling slices Sep 2, 2019
@hongweipeng
Copy link
Contributor Author

I have checked all of cur +=, Py_ssize_t cur and PySlice_Check() block, only list_ass_subscript needs to be modified.

def test_step_overflow(self):
a = [0, 1, 2, 3, 4]
a[1::sys.maxsize] = [0]
self.assertEqual(a[3::sys.maxsize], [3])
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add also the assertion for the whole list after modification?

self.assertEqual(a, [...])

@miss-islington
Copy link
Contributor

Thanks @hongweipeng for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-15729 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 8, 2019
…ythonGH-15639)

This is a complement to PR 13375.
(cherry picked from commit 3c87a66)

Co-authored-by: HongWeipeng <[email protected]>
miss-islington added a commit that referenced this pull request Sep 8, 2019
…H-15639)

This is a complement to PR 13375.
(cherry picked from commit 3c87a66)

Co-authored-by: HongWeipeng <[email protected]>
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
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.

5 participants