-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-34656: Avoid relying on signed overflow in _pickle memos. #9261
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
ea95daa to
59c974e
Compare
Modules/_pickle.c
Outdated
|
|
||
| error: | ||
| if (new_memo_size) { | ||
| i = new_memo_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this line is redundant now.
Modules/_pickle.c
Outdated
|
|
||
| /* Find the smallest valid table size >= min_size. */ | ||
| while (new_size < min_size && new_size > 0) | ||
| while (new_size < min_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this cause an infinite loop if min_size > PY_SSIZE_T_MAX?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will fix.
Modules/_pickle.c
Outdated
| */ | ||
| if (!(self->mt_used * 3 >= (self->mt_mask + 1) * 2)) | ||
| size_t triple_used = self->mt_used * 3; | ||
| if (triple_used > self->mt_used && triple_used < self->mt_allocated * 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
triple_used > self->mt_used
Is this a wrapping/overflow detection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
7975314 to
d8b389b
Compare
|
Thanks @benjaminp for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
…ythonGH-9261) (cherry picked from commit a4ae828) Co-authored-by: Benjamin Peterson <[email protected]>
|
GH-9465 is a backport of this pull request to the 3.7 branch. |
…ythonGH-9261) (cherry picked from commit a4ae828) Co-authored-by: Benjamin Peterson <[email protected]>
|
GH-9466 is a backport of this pull request to the 3.6 branch. |
…H-9261) (cherry picked from commit a4ae828) Co-authored-by: Benjamin Peterson <[email protected]>
…H-9261) (cherry picked from commit a4ae828) Co-authored-by: Benjamin Peterson <[email protected]>
https://bugs.python.org/issue1621