-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-148441: Avoid integer overflow in Expat's CharacterDataHandler #148904
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 9 commits
6138a78
8f8884b
588fa76
2e070e9
22edd46
9c3c841
01cf649
9e84a9b
98dd6f8
de2f62c
baaf37d
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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| :mod:`xml.parsers.expat`: Fix a heap buffer overflow in | ||
| :meth:`~xml.parsers.expat.xmlparser.CharacterDataHandler` | ||
| when the character data size exceeds the parser's | ||
| :attr:`buffer size <xml.parsers.expat.xmlparser.buffer_size>`. | ||
|
picnixz marked this conversation as resolved.
Outdated
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,7 +393,7 @@ my_CharacterDataHandler(void *userData, const XML_Char *data, int len) | |
| if (self->buffer == NULL) | ||
| call_character_handler(self, data, len); | ||
| else { | ||
| if ((self->buffer_used + len) > self->buffer_size) { | ||
| if (len > (self->buffer_size - self->buffer_used)) { | ||
|
Contributor
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. This looks like a fix to an integer overflow rather than a buffer overflow. Am missing something?
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. The cause is indeed an integer overflow, but I think the ASAN report says "heap-buffer overflow" in this case (so the result is a buffer overflow at the end). I'll just write "a crash" (people don't really care about the cause/exact result: if it crashes, it's bad; they can read the issue for more details).
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. I've updated the title to reflect what the PR did but I'll stay vague in the NEWS. |
||
| if (flush_character_buffer(self) < 0) | ||
| return; | ||
| /* handler might have changed; drop the rest on the floor | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.