Skip to content

Commit ff2b5bd

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 7faaf5a + 5da0579 commit ff2b5bd

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
- Session:
1515
. Fixed bug #77911 (Wrong warning for session.sid_bits_per_character). (cmb)
1616

17+
- SOAP:
18+
. Fixed bug #77945 (Segmentation fault when constructing SoapClient with
19+
WSDL_CACHE_BOTH). (Nikita)
20+
1721
- SPL:
1822
. Fixed bug #77024 (SplFileObject::__toString() may return array). (Craig
1923
Duncan)

ext/soap/php_sdl.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
11731173
return ctx.sdl;
11741174
}
11751175

1176-
#define WSDL_CACHE_VERSION 0x0f
1176+
#define WSDL_CACHE_VERSION 0x10
11771177

11781178
#define WSDL_CACHE_GET(ret,type,buf) memcpy(&ret,*buf,sizeof(type)); *buf += sizeof(type);
11791179
#define WSDL_CACHE_GET_INT(ret,buf) ret = ((unsigned char)(*buf)[0])|((unsigned char)(*buf)[1]<<8)|((unsigned char)(*buf)[2]<<16)|((int)(*buf)[3]<<24); *buf += 4;
@@ -1188,13 +1188,15 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
11881188
#define WSDL_CACHE_PUT_1(val,buf) smart_str_appendc(buf,val);
11891189
#define WSDL_CACHE_PUT_N(val,n,buf) smart_str_appendl(buf,(char*)val,n);
11901190

1191+
#define WSDL_NO_STRING_MARKER 0x7fffffff
1192+
11911193
static char* sdl_deserialize_string(char **in)
11921194
{
11931195
char *s;
11941196
int len;
11951197

11961198
WSDL_CACHE_GET_INT(len, in);
1197-
if (len == 0x7fffffff) {
1199+
if (len == WSDL_NO_STRING_MARKER) {
11981200
return NULL;
11991201
} else {
12001202
s = emalloc(len+1);
@@ -1209,7 +1211,7 @@ static void sdl_deserialize_key(HashTable* ht, void* data, char **in)
12091211
int len;
12101212

12111213
WSDL_CACHE_GET_INT(len, in);
1212-
if (len == 0) {
1214+
if (len == WSDL_NO_STRING_MARKER) {
12131215
zend_hash_next_index_insert_ptr(ht, data);
12141216
} else {
12151217
zend_hash_str_add_ptr(ht, *in, len, data);
@@ -1777,16 +1779,14 @@ static sdlPtr get_sdl_from_cache(const char *fn, const char *uri, time_t t, time
17771779

17781780
static void sdl_serialize_string(const char *str, smart_str *out)
17791781
{
1780-
int i;
1781-
17821782
if (str) {
1783-
i = strlen(str);
1783+
int i = strlen(str);
17841784
WSDL_CACHE_PUT_INT(i, out);
17851785
if (i > 0) {
17861786
WSDL_CACHE_PUT_N(str, i, out);
17871787
}
17881788
} else {
1789-
WSDL_CACHE_PUT_INT(0x7fffffff, out);
1789+
WSDL_CACHE_PUT_INT(WSDL_NO_STRING_MARKER, out);
17901790
}
17911791
}
17921792

@@ -1797,7 +1797,7 @@ static void sdl_serialize_key(zend_string *key, smart_str *out)
17971797
WSDL_CACHE_PUT_INT(ZSTR_LEN(key), out);
17981798
WSDL_CACHE_PUT_N(ZSTR_VAL(key), ZSTR_LEN(key), out);
17991799
} else {
1800-
WSDL_CACHE_PUT_INT(0, out);
1800+
WSDL_CACHE_PUT_INT(WSDL_NO_STRING_MARKER, out);
18011801
}
18021802
}
18031803

ext/soap/tests/bugs/bug29236.wsdl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<s:enumeration value="TemporarilySuspended" />
7676
<s:enumeration value="PasswordResetRequired" />
7777
<s:enumeration value="InvalidID" />
78+
<s:enumeration value="" /> <!-- For bug #77945 -->
7879
</s:restriction>
7980
</s:simpleType>
8081
<s:simpleType name="SessionStatus">
@@ -284,4 +285,4 @@
284285
<http:address location="http://isisdev1.tig.ucla.edu/iws/v4.asmx" />
285286
</port>
286287
</service>
287-
</definitions>
288+
</definitions>

ext/soap/tests/bugs/bug77945.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #77945: Segmentation fault when constructing SoapClient with WSDL_CACHE_BOTH
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('soap')) die('skip soap extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
10+
// The important part is to have a restriction enumeration with value="".
11+
$client = new SoapClient(__DIR__ . '/bug29236.wsdl', [
12+
'cache_wsdl' => WSDL_CACHE_BOTH
13+
]);
14+
15+
?>
16+
===DONE===
17+
--EXPECT--
18+
===DONE===

0 commit comments

Comments
 (0)