ext/soap: Fix integer overflow when decoding SOAP array indexes#21963
Open
LamentXU123 wants to merge 5 commits intophp:masterfrom
Open
ext/soap: Fix integer overflow when decoding SOAP array indexes#21963LamentXU123 wants to merge 5 commits intophp:masterfrom
LamentXU123 wants to merge 5 commits intophp:masterfrom
Conversation
Contributor
Author
|
Plus: Had to fix the bailout logic.... Now in the client side, if I raise a error when overflow is detected, the code will go to master_to_eval() and without xmlFreeDoc(response) and cause a memory leak. So in case of that I just had to add some logic to the bailout process to make sure xmldoc is free, although I hate it (;′⌒`) |
devnexen
reviewed
May 6, 2026
devnexen
reviewed
May 7, 2026
| static void master_to_zval_with_doc_cleanup(zval *ret, encodePtr encode, xmlNodePtr data, xmlDocPtr doc) | ||
| { | ||
| bool bailout = false; | ||
|
|
Member
There was a problem hiding this comment.
nit: you need ZVAL_UNDEF(ret); at the start and zval_ptr_dtor(ret) in the bailout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SOAP encoded array metadata such as arrayType, offset, and position is parsed into int indexes before being used for array placement. That is, this code:
Will resulted in:
Because the index overflows.
There is a TODO message to fix this. So I think people are aware of this bug before
I therefore wrote this to add checked decimal accumulation for SOAP array indexes and reject values that exceed int range. I Also reject auto-increment past INT_MAX before updating the next array position :)