-
-
Notifications
You must be signed in to change notification settings - Fork 34.9k
gh-153662: Fix crash when calling io.TextIOWrapper.seek() with malformed cookie
#153667
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
f5c8f10
cde0ad6
b9ec776
bf5fba6
64b052a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2781,7 +2781,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) | |
| textiowrapper_set_decoded_chars(self, decoded); | ||
|
|
||
| /* Skip chars_to_skip of the decoded characters. */ | ||
| /* gh-153662: Reject negative chars_to_skip*/ | ||
| /* gh-153662: Reject negative chars_to_skip */ | ||
| if (cookie.chars_to_skip < 0 || PyUnicode_GetLength(self->decoded_chars) < cookie.chars_to_skip) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't there a way to have a helper for validating this? what if the chars to skip are way too large? can we hit an overflow somehow?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there can hardly be an overflow. If Even in the case that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be hard but it can be crafted, as we did in your tests. So if possible, please add some more tests with malformed cookie values. |
||
| PyErr_SetString(PyExc_OSError, "can't restore logical file position"); | ||
| goto fail; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.