Skip to content

Commit 11fbe88

Browse files
committed
Fix SoapFault property destruction
Two issues: 1) We should not modify the object when we pass invalid values 2) We should reset the properties to their default value otherwise we get a UAF. Regressed in df219cc Closes GH-15248.
1 parent 67ce875 commit 11fbe88

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ PHP NEWS
4545

4646
- Soap:
4747
. Fixed bug #55639 (Digest autentication dont work). (nielsdos)
48+
. Fix SoapFault property destruction. (nielsdos)
4849

4950
- Standard:
5051
. Fix passing non-finite timeout values in stream functions. (nielsdos)

ext/soap/soap.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,13 @@ static void soap_fault_dtor_properties(zval *obj)
529529
zval_ptr_dtor(Z_FAULT_DETAIL_P(obj));
530530
zval_ptr_dtor(Z_FAULT_NAME_P(obj));
531531
zval_ptr_dtor(Z_FAULT_HEADERFAULT_P(obj));
532+
ZVAL_EMPTY_STRING(Z_FAULT_STRING_P(obj));
533+
ZVAL_NULL(Z_FAULT_CODE_P(obj));
534+
ZVAL_NULL(Z_FAULT_CODENS_P(obj));
535+
ZVAL_NULL(Z_FAULT_ACTOR_P(obj));
536+
ZVAL_NULL(Z_FAULT_DETAIL_P(obj));
537+
ZVAL_NULL(Z_FAULT_NAME_P(obj));
538+
ZVAL_NULL(Z_FAULT_HEADERFAULT_P(obj));
532539
}
533540

534541
/* {{{ SoapFault constructor */
@@ -550,9 +557,6 @@ PHP_METHOD(SoapFault, __construct)
550557
Z_PARAM_ZVAL_OR_NULL(headerfault)
551558
ZEND_PARSE_PARAMETERS_END();
552559

553-
/* Delete previously set properties */
554-
soap_fault_dtor_properties(ZEND_THIS);
555-
556560
if (code_str) {
557561
fault_code = ZSTR_VAL(code_str);
558562
fault_code_len = ZSTR_LEN(code_str);
@@ -571,6 +575,9 @@ PHP_METHOD(SoapFault, __construct)
571575
RETURN_THROWS();
572576
}
573577

578+
/* Delete previously set properties */
579+
soap_fault_dtor_properties(ZEND_THIS);
580+
574581
if (name != NULL && name_len == 0) {
575582
name = NULL;
576583
}

ext/soap/tests/SoapFault/gh14586.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ soap
66
<?php
77
$sf = new SoapFault(null, "x");
88
$sf->__construct(null, "x");
9+
try {
10+
$sf->__construct("", "");
11+
} catch (ValueError) {}
12+
$sf->__construct(null, "x", headerFault: []);
13+
var_dump($sf->headerfault);
14+
$sf->__construct(null, "x");
15+
var_dump($sf->headerfault);
916
?>
1017
DONE
1118
--EXPECT--
19+
array(0) {
20+
}
21+
NULL
1222
DONE

0 commit comments

Comments
 (0)