Skip to content

Commit de09315

Browse files
committed
Fix uninitialized soap lang_en string on ZTS
Replaces phpGH-19772. Fixes phpGH-19773.
1 parent e6c6333 commit de09315

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

ext/soap/php_http.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ int make_http_soap_request(
460460
if (request != buf) {
461461
zend_string_release_ex(request, 0);
462462
}
463-
add_soap_fault(this_ptr, "HTTP", "Unable to parse URL", NULL, NULL, SOAP_GLOBAL(lang_en));
463+
add_soap_fault(this_ptr, "HTTP", "Unable to parse URL", NULL, NULL, soap_lang_en);
464464
smart_str_free(&soap_headers_z);
465465
efree(http_msg);
466466
return FALSE;
@@ -474,7 +474,7 @@ int make_http_soap_request(
474474
if (request != buf) {
475475
zend_string_release_ex(request, 0);
476476
}
477-
add_soap_fault(this_ptr, "HTTP", "Unknown protocol. Only http and https are allowed.", NULL, NULL, SOAP_GLOBAL(lang_en));
477+
add_soap_fault(this_ptr, "HTTP", "Unknown protocol. Only http and https are allowed.", NULL, NULL, soap_lang_en);
478478
smart_str_free(&soap_headers_z);
479479
efree(http_msg);
480480
return FALSE;
@@ -487,7 +487,7 @@ int make_http_soap_request(
487487
if (request != buf) {
488488
zend_string_release_ex(request, 0);
489489
}
490-
add_soap_fault(this_ptr, "HTTP", "SSL support is not available in this build", NULL, NULL, SOAP_GLOBAL(lang_en));
490+
add_soap_fault(this_ptr, "HTTP", "SSL support is not available in this build", NULL, NULL, soap_lang_en);
491491
PG(allow_url_fopen) = old_allow_url_fopen;
492492
smart_str_free(&soap_headers_z);
493493
efree(http_msg);
@@ -540,7 +540,7 @@ int make_http_soap_request(
540540
if (request != buf) {
541541
zend_string_release_ex(request, 0);
542542
}
543-
add_soap_fault(this_ptr, "HTTP", "Could not connect to host", NULL, NULL, SOAP_GLOBAL(lang_en));
543+
add_soap_fault(this_ptr, "HTTP", "Could not connect to host", NULL, NULL, soap_lang_en);
544544
PG(allow_url_fopen) = old_allow_url_fopen;
545545
smart_str_free(&soap_headers_z);
546546
efree(http_msg);
@@ -911,14 +911,14 @@ int make_http_soap_request(
911911
php_stream_close(stream);
912912
convert_to_null(Z_CLIENT_HTTPURL_P(this_ptr));
913913
ZVAL_NULL(Z_CLIENT_USE_PROXY_P(this_ptr));
914-
add_soap_fault(this_ptr, "HTTP", "Failed Sending HTTP SOAP request", NULL, NULL, SOAP_GLOBAL(lang_en));
914+
add_soap_fault(this_ptr, "HTTP", "Failed Sending HTTP SOAP request", NULL, NULL, soap_lang_en);
915915
smart_str_free(&soap_headers_z);
916916
efree(http_msg);
917917
return FALSE;
918918
}
919919
smart_str_free(&soap_headers);
920920
} else {
921-
add_soap_fault(this_ptr, "HTTP", "Failed to create stream??", NULL, NULL, SOAP_GLOBAL(lang_en));
921+
add_soap_fault(this_ptr, "HTTP", "Failed to create stream??", NULL, NULL, soap_lang_en);
922922
smart_str_free(&soap_headers_z);
923923
efree(http_msg);
924924
return FALSE;
@@ -935,7 +935,7 @@ int make_http_soap_request(
935935
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(this_ptr));
936936
php_stream_close(stream);
937937
ZVAL_NULL(Z_CLIENT_USE_PROXY_P(this_ptr));
938-
add_soap_fault(this_ptr, "HTTP", "Error Fetching http headers", NULL, NULL, SOAP_GLOBAL(lang_en));
938+
add_soap_fault(this_ptr, "HTTP", "Error Fetching http headers", NULL, NULL, soap_lang_en);
939939
smart_str_free(&soap_headers_z);
940940
efree(http_msg);
941941
return FALSE;
@@ -1124,7 +1124,7 @@ int make_http_soap_request(
11241124
php_stream_close(stream);
11251125
zend_string_release_ex(http_headers, 0);
11261126
ZVAL_NULL(Z_CLIENT_USE_PROXY_P(this_ptr));
1127-
add_soap_fault(this_ptr, "HTTP", "Error Fetching http body, No Content-Length, connection closed or chunked data", NULL, NULL, SOAP_GLOBAL(lang_en));
1127+
add_soap_fault(this_ptr, "HTTP", "Error Fetching http body, No Content-Length, connection closed or chunked data", NULL, NULL, soap_lang_en);
11281128
if (http_msg) {
11291129
efree(http_msg);
11301130
}
@@ -1190,7 +1190,7 @@ int make_http_soap_request(
11901190
uri = new_uri;
11911191

11921192
if (--redirect_max < 1) {
1193-
add_soap_fault(this_ptr, "HTTP", "Redirection limit reached, aborting", NULL, NULL, SOAP_GLOBAL(lang_en));
1193+
add_soap_fault(this_ptr, "HTTP", "Redirection limit reached, aborting", NULL, NULL, soap_lang_en);
11941194
smart_str_free(&soap_headers_z);
11951195
efree(http_msg);
11961196
return FALSE;
@@ -1326,7 +1326,7 @@ int make_http_soap_request(
13261326
if (http_msg) {
13271327
efree(http_msg);
13281328
}
1329-
add_soap_fault(this_ptr, "HTTP", "Unknown Content-Encoding", NULL, NULL, SOAP_GLOBAL(lang_en));
1329+
add_soap_fault(this_ptr, "HTTP", "Unknown Content-Encoding", NULL, NULL, soap_lang_en);
13301330
return FALSE;
13311331
}
13321332
zend_call_known_function(decompression_fn, NULL, NULL, &retval, 1, params, NULL);
@@ -1338,7 +1338,7 @@ int make_http_soap_request(
13381338
efree(content_encoding);
13391339
zend_string_release_ex(http_headers, 0);
13401340
zend_string_release_ex(http_body, 0);
1341-
add_soap_fault(this_ptr, "HTTP", "Can't uncompress compressed response", NULL, NULL, SOAP_GLOBAL(lang_en));
1341+
add_soap_fault(this_ptr, "HTTP", "Can't uncompress compressed response", NULL, NULL, soap_lang_en);
13421342
if (http_msg) {
13431343
efree(http_msg);
13441344
}
@@ -1372,7 +1372,7 @@ int make_http_soap_request(
13721372
if (error) {
13731373
zval_ptr_dtor(return_value);
13741374
ZVAL_UNDEF(return_value);
1375-
add_soap_fault(this_ptr, "HTTP", http_msg, NULL, NULL, SOAP_GLOBAL(lang_en));
1375+
add_soap_fault(this_ptr, "HTTP", http_msg, NULL, NULL, soap_lang_en);
13761376
efree(http_msg);
13771377
return FALSE;
13781378
}

ext/soap/php_packet_soap.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
4040
response = soap_xmlParseMemory(buffer, buffer_size);
4141

4242
if (!response) {
43-
add_soap_fault(this_ptr, "Client", "looks like we got no XML document", NULL, NULL, SOAP_GLOBAL(lang_en));
43+
add_soap_fault(this_ptr, "Client", "looks like we got no XML document", NULL, NULL, soap_lang_en);
4444
return false;
4545
}
4646
if (xmlGetIntSubset(response) != NULL) {
47-
add_soap_fault(this_ptr, "Client", "DTD are not supported by SOAP", NULL, NULL, SOAP_GLOBAL(lang_en));
47+
add_soap_fault(this_ptr, "Client", "DTD are not supported by SOAP", NULL, NULL, soap_lang_en);
4848
xmlFreeDoc(response);
4949
return false;
5050
}
@@ -63,32 +63,32 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
6363
envelope_ns = SOAP_1_2_ENV_NAMESPACE;
6464
soap_version = SOAP_1_2;
6565
} else {
66-
add_soap_fault(this_ptr, "VersionMismatch", "Wrong Version", NULL, NULL, SOAP_GLOBAL(lang_en));
66+
add_soap_fault(this_ptr, "VersionMismatch", "Wrong Version", NULL, NULL, soap_lang_en);
6767
xmlFreeDoc(response);
6868
return false;
6969
}
7070
}
7171
trav = trav->next;
7272
}
7373
if (env == NULL) {
74-
add_soap_fault(this_ptr, "Client", "looks like we got XML without \"Envelope\" element", NULL, NULL, SOAP_GLOBAL(lang_en));
74+
add_soap_fault(this_ptr, "Client", "looks like we got XML without \"Envelope\" element", NULL, NULL, soap_lang_en);
7575
xmlFreeDoc(response);
7676
return false;
7777
}
7878

7979
attr = env->properties;
8080
while (attr != NULL) {
8181
if (attr->ns == NULL) {
82-
add_soap_fault(this_ptr, "Client", "A SOAP Envelope element cannot have non Namespace qualified attributes", NULL, NULL, SOAP_GLOBAL(lang_en));
82+
add_soap_fault(this_ptr, "Client", "A SOAP Envelope element cannot have non Namespace qualified attributes", NULL, NULL, soap_lang_en);
8383
xmlFreeDoc(response);
8484
return false;
8585
} else if (attr_is_equal_ex(attr,"encodingStyle",SOAP_1_2_ENV_NAMESPACE)) {
8686
if (soap_version == SOAP_1_2) {
87-
add_soap_fault(this_ptr, "Client", "encodingStyle cannot be specified on the Envelope", NULL, NULL, SOAP_GLOBAL(lang_en));
87+
add_soap_fault(this_ptr, "Client", "encodingStyle cannot be specified on the Envelope", NULL, NULL, soap_lang_en);
8888
xmlFreeDoc(response);
8989
return false;
9090
} else if (strcmp((char*)attr->children->content, SOAP_1_1_ENC_NAMESPACE) != 0) {
91-
add_soap_fault(this_ptr, "Client", "Unknown data encoding style", NULL, NULL, SOAP_GLOBAL(lang_en));
91+
add_soap_fault(this_ptr, "Client", "Unknown data encoding style", NULL, NULL, soap_lang_en);
9292
xmlFreeDoc(response);
9393
return false;
9494
}
@@ -120,33 +120,33 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
120120
trav = trav->next;
121121
}
122122
if (body == NULL) {
123-
add_soap_fault(this_ptr, "Client", "Body must be present in a SOAP envelope", NULL, NULL, SOAP_GLOBAL(lang_en));
123+
add_soap_fault(this_ptr, "Client", "Body must be present in a SOAP envelope", NULL, NULL, soap_lang_en);
124124
xmlFreeDoc(response);
125125
return false;
126126
}
127127
attr = body->properties;
128128
while (attr != NULL) {
129129
if (attr->ns == NULL) {
130130
if (soap_version == SOAP_1_2) {
131-
add_soap_fault(this_ptr, "Client", "A SOAP Body element cannot have non Namespace qualified attributes", NULL, NULL, SOAP_GLOBAL(lang_en));
131+
add_soap_fault(this_ptr, "Client", "A SOAP Body element cannot have non Namespace qualified attributes", NULL, NULL, soap_lang_en);
132132
xmlFreeDoc(response);
133133
return false;
134134
}
135135
} else if (attr_is_equal_ex(attr,"encodingStyle",SOAP_1_2_ENV_NAMESPACE)) {
136136
if (soap_version == SOAP_1_2) {
137-
add_soap_fault(this_ptr, "Client", "encodingStyle cannot be specified on the Body", NULL, NULL, SOAP_GLOBAL(lang_en));
137+
add_soap_fault(this_ptr, "Client", "encodingStyle cannot be specified on the Body", NULL, NULL, soap_lang_en);
138138
xmlFreeDoc(response);
139139
return false;
140140
} else if (strcmp((char*)attr->children->content, SOAP_1_1_ENC_NAMESPACE) != 0) {
141-
add_soap_fault(this_ptr, "Client", "Unknown data encoding style", NULL, NULL, SOAP_GLOBAL(lang_en));
141+
add_soap_fault(this_ptr, "Client", "Unknown data encoding style", NULL, NULL, soap_lang_en);
142142
xmlFreeDoc(response);
143143
return false;
144144
}
145145
}
146146
attr = attr->next;
147147
}
148148
if (trav != NULL && soap_version == SOAP_1_2) {
149-
add_soap_fault(this_ptr, "Client", "A SOAP 1.2 envelope can contain only Header and Body", NULL, NULL, SOAP_GLOBAL(lang_en));
149+
add_soap_fault(this_ptr, "Client", "A SOAP 1.2 envelope can contain only Header and Body", NULL, NULL, soap_lang_en);
150150
xmlFreeDoc(response);
151151
return false;
152152
}
@@ -155,16 +155,16 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
155155
attr = head->properties;
156156
while (attr != NULL) {
157157
if (attr->ns == NULL) {
158-
add_soap_fault(this_ptr, "Client", "A SOAP Header element cannot have non Namespace qualified attributes", NULL, NULL, SOAP_GLOBAL(lang_en));
158+
add_soap_fault(this_ptr, "Client", "A SOAP Header element cannot have non Namespace qualified attributes", NULL, NULL, soap_lang_en);
159159
xmlFreeDoc(response);
160160
return false;
161161
} else if (attr_is_equal_ex(attr,"encodingStyle",SOAP_1_2_ENV_NAMESPACE)) {
162162
if (soap_version == SOAP_1_2) {
163-
add_soap_fault(this_ptr, "Client", "encodingStyle cannot be specified on the Header", NULL, NULL, SOAP_GLOBAL(lang_en));
163+
add_soap_fault(this_ptr, "Client", "encodingStyle cannot be specified on the Header", NULL, NULL, soap_lang_en);
164164
xmlFreeDoc(response);
165165
return false;
166166
} else if (strcmp((char*)attr->children->content, SOAP_1_1_ENC_NAMESPACE) != 0) {
167-
add_soap_fault(this_ptr, "Client", "Unknown data encoding style", NULL, NULL, SOAP_GLOBAL(lang_en));
167+
add_soap_fault(this_ptr, "Client", "Unknown data encoding style", NULL, NULL, soap_lang_en);
168168
xmlFreeDoc(response);
169169
return false;
170170
}

ext/soap/php_soap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,10 @@ ZEND_BEGIN_MODULE_GLOBALS(soap)
171171
HashTable wsdl_cache;
172172
int cur_uniq_ref;
173173
HashTable *ref_map;
174-
zend_string *lang_en;
175174
ZEND_END_MODULE_GLOBALS(soap)
176175

176+
extern zend_string *soap_lang_en;
177+
177178
#ifdef ZTS
178179
#include "TSRM.h"
179180
#endif

ext/soap/soap.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ static zend_object_handlers soap_server_object_handlers;
194194
static zend_object_handlers soap_url_object_handlers;
195195
static zend_object_handlers soap_sdl_object_handlers;
196196

197+
zend_string *soap_lang_en;
198+
197199
typedef struct {
198200
soapServicePtr service;
199201
zend_object std;
@@ -472,7 +474,7 @@ PHP_MSHUTDOWN_FUNCTION(soap)
472474
zend_hash_destroy(SOAP_GLOBAL(mem_cache));
473475
free(SOAP_GLOBAL(mem_cache));
474476
}
475-
zend_string_release_ex(SOAP_GLOBAL(lang_en), true);
477+
zend_string_release_ex(soap_lang_en, true);
476478
UNREGISTER_INI_ENTRIES();
477479
return SUCCESS;
478480
}
@@ -552,7 +554,7 @@ PHP_MINIT_FUNCTION(soap)
552554
old_error_handler = zend_error_cb;
553555
zend_error_cb = soap_error_handler;
554556

555-
SOAP_GLOBAL(lang_en) = zend_string_init_interned(ZEND_STRL("en"), true);
557+
soap_lang_en = zend_string_init_interned(ZEND_STRL("en"), true);
556558

557559
return SUCCESS;
558560
}
@@ -712,7 +714,7 @@ PHP_METHOD(SoapFault, __construct)
712714
}
713715

714716
this_ptr = ZEND_THIS;
715-
set_soap_fault(this_ptr, fault_code_ns, fault_code, fault_string, fault_actor, details, name, lang);
717+
set_soap_fault(this_ptr, fault_code_ns, fault_code, fault_string, fault_actor, details, name, soap_lang_en);
716718
if (headerfault != NULL) {
717719
ZVAL_COPY(Z_FAULT_HEADERFAULT_P(this_ptr), headerfault);
718720
}
@@ -1853,7 +1855,7 @@ static ZEND_NORETURN void soap_server_fault(char* code, char* string, char *acto
18531855

18541856
static ZEND_NORETURN void soap_server_fault_en(char* code, char* string, char *actor, zval* details, zend_string* name)
18551857
{
1856-
soap_server_fault(code, string, actor, details, name, SOAP_GLOBAL(lang_en));
1858+
soap_server_fault(code, string, actor, details, name, soap_lang_en);
18571859
}
18581860

18591861
static zend_never_inline ZEND_COLD void soap_real_error_handler(int error_num, zend_string *error_filename, const uint32_t error_lineno, zend_string *message) /* {{{ */
@@ -1922,7 +1924,7 @@ static zend_never_inline ZEND_COLD void soap_real_error_handler(int error_num, z
19221924

19231925
}
19241926
ZVAL_NULL(&fault_obj);
1925-
set_soap_fault(&fault_obj, NULL, code, ZSTR_VAL(buffer), NULL, &outbuf, NULL, SOAP_GLOBAL(lang_en));
1927+
set_soap_fault(&fault_obj, NULL, code, ZSTR_VAL(buffer), NULL, &outbuf, NULL, soap_lang_en);
19261928
zend_string_release(buffer);
19271929
fault = 1;
19281930
}
@@ -2935,7 +2937,7 @@ static void add_soap_fault_ex(zval *fault, zval *obj, char *fault_code, char *fa
29352937

29362938
static void add_soap_fault_ex_en(zval *fault, zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail)
29372939
{
2938-
add_soap_fault_ex(fault, obj, fault_code, fault_string, fault_actor, fault_detail, SOAP_GLOBAL(lang_en));
2940+
add_soap_fault_ex(fault, obj, fault_code, fault_string, fault_actor, fault_detail, soap_lang_en);
29392941
}
29402942

29412943
void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail, zend_string *lang) /* {{{ */
@@ -2947,7 +2949,7 @@ void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault
29472949

29482950
static void add_soap_fault_en(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail)
29492951
{
2950-
add_soap_fault(obj, fault_code, fault_string, fault_actor, fault_detail, SOAP_GLOBAL(lang_en));
2952+
add_soap_fault(obj, fault_code, fault_string, fault_actor, fault_detail, soap_lang_en);
29512953
}
29522954

29532955
static void set_soap_fault(zval *obj, const char *fault_code_ns, const char *fault_code, const char *fault_string, const char *fault_actor, zval *fault_detail, zend_string *name, zend_string *lang) /* {{{ */

0 commit comments

Comments
 (0)