-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
bpo-36819: Fix crashes in built-in encoders with weird error handlers #28593
bpo-36819: Fix crashes in built-in encoders with weird error handlers #28593
Conversation
If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults.
I need to add more tests for exceptions raised when an error handler returns invalid result, and analyze decoders. |
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.
Honestly, I'm not sure that it's worth it to handle this weird case: https://bugs.python.org/issue36819#msg402826
There are existing tests for position out of range (even negative values). They just are not harsh enough to cause a crash. The code needs to be changed even if we restrict returned values for error handlers. |
I have added more tests and it is now ready for review. |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
GH-92136 is a backport of this pull request to the 3.10 branch. |
GH-92137 is a backport of this pull request to the 3.9 branch. |
…pythonGH-28593) If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults. (cherry picked from commit 18b07d7) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…GH-28593) If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults. (cherry picked from commit 18b07d7) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…GH-28593) If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults. (cherry picked from commit 18b07d7) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…pythonGH-28593) If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults. (cherry picked from commit 18b07d7) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
If the error handler returns position less or equal than the starting
position of non-encodable characters, most of built-in encoders didn't
properly re-size the output buffer. This led to out-of-bounds writes,
and segfaults.
https://bugs.python.org/issue36819
#81000