Skip to content

Commit

Permalink
Merge branch 'PHP-7.2' into PHP-7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Apr 29, 2019
2 parents 7faaf5a + 5da0579 commit ff2b5bd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ PHP NEWS
- Session:
. Fixed bug #77911 (Wrong warning for session.sid_bits_per_character). (cmb)

- SOAP:
. Fixed bug #77945 (Segmentation fault when constructing SoapClient with
WSDL_CACHE_BOTH). (Nikita)

- SPL:
. Fixed bug #77024 (SplFileObject::__toString() may return array). (Craig
Duncan)
Expand Down
16 changes: 8 additions & 8 deletions ext/soap/php_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
return ctx.sdl;
}

#define WSDL_CACHE_VERSION 0x0f
#define WSDL_CACHE_VERSION 0x10

#define WSDL_CACHE_GET(ret,type,buf) memcpy(&ret,*buf,sizeof(type)); *buf += sizeof(type);
#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;
Expand All @@ -1188,13 +1188,15 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
#define WSDL_CACHE_PUT_1(val,buf) smart_str_appendc(buf,val);
#define WSDL_CACHE_PUT_N(val,n,buf) smart_str_appendl(buf,(char*)val,n);

#define WSDL_NO_STRING_MARKER 0x7fffffff

static char* sdl_deserialize_string(char **in)
{
char *s;
int len;

WSDL_CACHE_GET_INT(len, in);
if (len == 0x7fffffff) {
if (len == WSDL_NO_STRING_MARKER) {
return NULL;
} else {
s = emalloc(len+1);
Expand All @@ -1209,7 +1211,7 @@ static void sdl_deserialize_key(HashTable* ht, void* data, char **in)
int len;

WSDL_CACHE_GET_INT(len, in);
if (len == 0) {
if (len == WSDL_NO_STRING_MARKER) {
zend_hash_next_index_insert_ptr(ht, data);
} else {
zend_hash_str_add_ptr(ht, *in, len, data);
Expand Down Expand Up @@ -1777,16 +1779,14 @@ static sdlPtr get_sdl_from_cache(const char *fn, const char *uri, time_t t, time

static void sdl_serialize_string(const char *str, smart_str *out)
{
int i;

if (str) {
i = strlen(str);
int i = strlen(str);
WSDL_CACHE_PUT_INT(i, out);
if (i > 0) {
WSDL_CACHE_PUT_N(str, i, out);
}
} else {
WSDL_CACHE_PUT_INT(0x7fffffff, out);
WSDL_CACHE_PUT_INT(WSDL_NO_STRING_MARKER, out);
}
}

Expand All @@ -1797,7 +1797,7 @@ static void sdl_serialize_key(zend_string *key, smart_str *out)
WSDL_CACHE_PUT_INT(ZSTR_LEN(key), out);
WSDL_CACHE_PUT_N(ZSTR_VAL(key), ZSTR_LEN(key), out);
} else {
WSDL_CACHE_PUT_INT(0, out);
WSDL_CACHE_PUT_INT(WSDL_NO_STRING_MARKER, out);
}
}

Expand Down
3 changes: 2 additions & 1 deletion ext/soap/tests/bugs/bug29236.wsdl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<s:enumeration value="TemporarilySuspended" />
<s:enumeration value="PasswordResetRequired" />
<s:enumeration value="InvalidID" />
<s:enumeration value="" /> <!-- For bug #77945 -->
</s:restriction>
</s:simpleType>
<s:simpleType name="SessionStatus">
Expand Down Expand Up @@ -284,4 +285,4 @@
<http:address location="http://isisdev1.tig.ucla.edu/iws/v4.asmx" />
</port>
</service>
</definitions>
</definitions>
18 changes: 18 additions & 0 deletions ext/soap/tests/bugs/bug77945.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Bug #77945: Segmentation fault when constructing SoapClient with WSDL_CACHE_BOTH
--SKIPIF--
<?php
if (!extension_loaded('soap')) die('skip soap extension not available');
?>
--FILE--
<?php

// The important part is to have a restriction enumeration with value="".
$client = new SoapClient(__DIR__ . '/bug29236.wsdl', [
'cache_wsdl' => WSDL_CACHE_BOTH
]);

?>
===DONE===
--EXPECT--
===DONE===

0 comments on commit ff2b5bd

Please sign in to comment.