Skip to content

Commit c8eaca0

Browse files
committed
Added type checks
1 parent 0c136a2 commit c8eaca0

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

ext/soap/php_encoding.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,15 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
404404
encodePtr enc = NULL;
405405
HashTable *ht = Z_OBJPROP_P(data);
406406

407-
if (zend_hash_find(ht, "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
407+
if (zend_hash_find(ht, "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
408+
Z_TYPE_PP(ztype) != IS_LONG) {
408409
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
409410
}
410411

411-
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) {
412-
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) {
412+
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS &&
413+
Z_TYPE_PP(zstype) == IS_STRING) {
414+
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS &&
415+
Z_TYPE_PP(zns) == IS_STRING) {
413416
enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype));
414417
} else {
415418
zns = NULL;
@@ -445,19 +448,23 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
445448
}
446449

447450
if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) {
448-
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) {
449-
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) {
451+
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS &&
452+
Z_TYPE_PP(zstype) == IS_STRING) {
453+
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS &&
454+
Z_TYPE_PP(zns) == IS_STRING) {
450455
set_ns_and_type_ex(node, Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype));
451456
} else {
452457
set_ns_and_type_ex(node, NULL, Z_STRVAL_PP(zstype));
453458
}
454459
}
455460
}
456461

457-
if (zend_hash_find(ht, "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS) {
462+
if (zend_hash_find(ht, "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS &&
463+
Z_TYPE_PP(zname) == IS_STRING) {
458464
xmlNodeSetName(node, BAD_CAST(Z_STRVAL_PP(zname)));
459465
}
460-
if (zend_hash_find(ht, "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS) {
466+
if (zend_hash_find(ht, "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS &&
467+
Z_TYPE_PP(zname) == IS_STRING) {
461468
xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_PP(znamens));
462469
xmlSetNs(node, nsp);
463470
}

ext/soap/soap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3979,7 +3979,8 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function
39793979
}
39803980

39813981
if (version == SOAP_1_1) {
3982-
if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) {
3982+
if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS &&
3983+
Z_TYPE_PP(tmp) == IS_STRING) {
39833984
size_t new_len;
39843985
xmlNodePtr node = xmlNewNode(NULL, BAD_CAST("faultcode"));
39853986
char *str = php_escape_html_entities((unsigned char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
@@ -4004,7 +4005,8 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function
40044005
}
40054006
detail_name = "detail";
40064007
} else {
4007-
if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) {
4008+
if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS &&
4009+
Z_TYPE_PP(tmp) == IS_STRING) {
40084010
size_t new_len;
40094011
xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Code"), NULL);
40104012
char *str = php_escape_html_entities((unsigned char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);

0 commit comments

Comments
 (0)