Skip to content

Commit 6138a78

Browse files
gh-148535: Fix heap buffer overflow in pyexpat CharacterDataHandler
1 parent 3b93979 commit 6138a78

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix heap buffer overflow in pyexpat CharacterDataHandler, which is caused by
2+
two signed intergets added up.

Modules/pyexpat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ my_CharacterDataHandler(void *userData, const XML_Char *data, int len)
393393
if (self->buffer == NULL)
394394
call_character_handler(self, data, len);
395395
else {
396-
if ((self->buffer_used + len) > self->buffer_size) {
396+
if (len > (self->buffer_size - self->buffer_used)) {
397397
if (flush_character_buffer(self) < 0)
398398
return;
399399
/* handler might have changed; drop the rest on the floor

0 commit comments

Comments
 (0)