2323#include "ext/standard/md5.h"
2424#include "ext/standard/php_random.h"
2525
26+ static char * get_http_header_value_nodup (char * headers , char * type , size_t * len );
2627static char * get_http_header_value (char * headers , char * type );
2728static zend_string * get_http_body (php_stream * socketd , int close , char * headers );
2829static zend_string * get_http_headers (php_stream * socketd );
@@ -350,6 +351,7 @@ int make_http_soap_request(zval *this_ptr,
350351 int use_ssl ;
351352 zend_string * http_body ;
352353 char * content_type , * http_version , * cookie_itt ;
354+ size_t cookie_len ;
353355 int http_close ;
354356 zend_string * http_headers ;
355357 char * connection ;
@@ -968,8 +970,9 @@ int make_http_soap_request(zval *this_ptr,
968970 we shouldn't be changing urls so path doesn't
969971 matter too much
970972 */
971- cookie_itt = strstr (ZSTR_VAL (http_headers ), "Set-Cookie: " );
972- while (cookie_itt ) {
973+ cookie_itt = ZSTR_VAL (http_headers );
974+
975+ while ((cookie_itt = get_http_header_value_nodup (cookie_itt , "Set-Cookie: " , & cookie_len ))) {
973976 char * cookie ;
974977 char * eqpos , * sempos ;
975978 zval * cookies ;
@@ -981,7 +984,7 @@ int make_http_soap_request(zval *this_ptr,
981984 cookies = zend_hash_str_update (Z_OBJPROP_P (this_ptr ), "_cookies" , sizeof ("_cookies" )- 1 , & tmp_cookies );
982985 }
983986
984- cookie = get_http_header_value (cookie_itt ,"Set-Cookie: " );
987+ cookie = estrndup (cookie_itt , cookie_len );
985988
986989 eqpos = strstr (cookie , "=" );
987990 sempos = strstr (cookie , ";" );
@@ -1039,7 +1042,7 @@ int make_http_soap_request(zval *this_ptr,
10391042 smart_str_free (& name );
10401043 }
10411044
1042- cookie_itt = strstr ( cookie_itt + sizeof ( "Set-Cookie: " ), "Set-Cookie: " ) ;
1045+ cookie_itt = cookie_itt + cookie_len ;
10431046 efree (cookie );
10441047 }
10451048
@@ -1357,7 +1360,7 @@ int make_http_soap_request(zval *this_ptr,
13571360 return TRUE;
13581361}
13591362
1360- static char * get_http_header_value (char * headers , char * type )
1363+ static char * get_http_header_value_nodup (char * headers , char * type , size_t * len )
13611364{
13621365 char * pos , * tmp = NULL ;
13631366 int typelen , headerslen ;
@@ -1394,7 +1397,9 @@ static char *get_http_header_value(char *headers, char *type)
13941397 eol -- ;
13951398 }
13961399 }
1397- return estrndup (tmp , eol - tmp );
1400+
1401+ * len = eol - tmp ;
1402+ return tmp ;
13981403 }
13991404
14001405 /* find next line */
@@ -1408,6 +1413,20 @@ static char *get_http_header_value(char *headers, char *type)
14081413 return NULL ;
14091414}
14101415
1416+ static char * get_http_header_value (char * headers , char * type )
1417+ {
1418+ size_t len ;
1419+ char * value ;
1420+
1421+ value = get_http_header_value_nodup (headers , type , & len );
1422+
1423+ if (value ) {
1424+ return estrndup (value , len );
1425+ }
1426+
1427+ return NULL ;
1428+ }
1429+
14111430static zend_string * get_http_body (php_stream * stream , int close , char * headers )
14121431{
14131432 zend_string * http_buf = NULL ;
0 commit comments