ext/soap: Fix SOAP classmap validation for integer keys - #22884
ext/soap: Fix SOAP classmap validation for integer keys#22884LamentXU123 wants to merge 7 commits into
Conversation
|
could you add the following test please ? |
732faef to
751d593
Compare
|
This is indeed a bug when SoapClient::_classmap can be reflected as a packed array :) |
|
I would like to see the following in those new tests |
| } | ||
| /* }}} */ | ||
|
|
||
| static bool soap_class_map_is_valid(const HashTable *class_map) |
There was a problem hiding this comment.
name a bit misleading since you check only the keys
Co-Authored-By: David CARLIER <devnexen@gmail.com>
| Z_TYPE_P(tmp) == IS_ARRAY) { | ||
| if (UNEXPECTED(HT_IS_PACKED(Z_ARRVAL_P(tmp)))) { | ||
| if (UNEXPECTED(!soap_class_map_has_only_string_keys(Z_ARRVAL_P(tmp)))) { | ||
| php_error_docref(NULL, E_ERROR, "'classmap' option must be an associative array"); |
There was a problem hiding this comment.
since we re in the "TODO mindset", what about having a ValueError instead (to match the server side) ?
There was a problem hiding this comment.
I don't have strong opinions on this tho. But sure, this makes the behavior of SoapClient and SoapServer the same.
| if (UNEXPECTED(!soap_class_map_has_only_string_keys(Z_ARRVAL_P(tmp)))) { | ||
| zend_argument_value_error(2, "\"classmap\" option must be an associative array"); | ||
| if (context) { | ||
| zend_list_delete(context->res); |
There was a problem hiding this comment.
If we throw error here, the code won't goes to ZVAL_RES(). So we need to manually delete this.
the context is created with an additional ref:
context = php_stream_context_from_zval(tmp, 1);
Z_ADDREF_P(tmp);There was a problem hiding this comment.
yes but in this case we can avoid this gymnastic by checking this before instantiating the stream context.
|
if we have a packed array with one element but we unset it, should not trigger exception right ? might be a nice test case. |
| RETURN_THROWS(); | ||
| } | ||
|
|
||
| SOAP_CLIENT_BEGIN_CODE(); |
There was a problem hiding this comment.
I think global $soap_version needs to be initialised since this property has no default.
| @@ -2233,12 +2225,33 @@ | |||
| } | |||
| if ((tmp = zend_hash_str_find(ht, "classmap", sizeof("classmap")-1)) != NULL && | |||
| Z_TYPE_P(tmp) == IS_ARRAY) { | |||
There was a problem hiding this comment.
it might be preferable to throw if this is not an array
Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com>
Previously, SOAP only rejected packed arrays, which still allowed sparse integer-keyed arrays and mixed string integer-keyed arrays to be accepted.
Since
classmapis expected to be an associative mapping, arrays containing integer keys are now rejected consistently.