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 ;
@@ -960,8 +962,9 @@ int make_http_soap_request(zval *this_ptr,
960962 we shouldn't be changing urls so path doesn't
961963 matter too much
962964 */
963- cookie_itt = strstr (ZSTR_VAL (http_headers ), "Set-Cookie: " );
964- while (cookie_itt ) {
965+ cookie_itt = ZSTR_VAL (http_headers );
966+
967+ while ((cookie_itt = get_http_header_value_nodup (cookie_itt , "Set-Cookie: " , & cookie_len ))) {
965968 char * cookie ;
966969 char * eqpos , * sempos ;
967970 zval * cookies ;
@@ -973,7 +976,7 @@ int make_http_soap_request(zval *this_ptr,
973976 cookies = zend_hash_str_update (Z_OBJPROP_P (this_ptr ), "_cookies" , sizeof ("_cookies" )- 1 , & tmp_cookies );
974977 }
975978
976- cookie = get_http_header_value (cookie_itt ,"Set-Cookie: " );
979+ cookie = estrndup (cookie_itt , cookie_len );
977980
978981 eqpos = strstr (cookie , "=" );
979982 sempos = strstr (cookie , ";" );
@@ -1031,7 +1034,7 @@ int make_http_soap_request(zval *this_ptr,
10311034 smart_str_free (& name );
10321035 }
10331036
1034- cookie_itt = strstr ( cookie_itt + sizeof ( "Set-Cookie: " ), "Set-Cookie: " ) ;
1037+ cookie_itt = cookie_itt + cookie_len ;
10351038 efree (cookie );
10361039 }
10371040
@@ -1349,7 +1352,7 @@ int make_http_soap_request(zval *this_ptr,
13491352 return TRUE;
13501353}
13511354
1352- static char * get_http_header_value (char * headers , char * type )
1355+ static char * get_http_header_value_nodup (char * headers , char * type , size_t * len )
13531356{
13541357 char * pos , * tmp = NULL ;
13551358 int typelen , headerslen ;
@@ -1386,7 +1389,9 @@ static char *get_http_header_value(char *headers, char *type)
13861389 eol -- ;
13871390 }
13881391 }
1389- return estrndup (tmp , eol - tmp );
1392+
1393+ * len = eol - tmp ;
1394+ return tmp ;
13901395 }
13911396
13921397 /* find next line */
@@ -1400,6 +1405,20 @@ static char *get_http_header_value(char *headers, char *type)
14001405 return NULL ;
14011406}
14021407
1408+ static char * get_http_header_value (char * headers , char * type )
1409+ {
1410+ size_t len ;
1411+ char * value ;
1412+
1413+ value = get_http_header_value_nodup (headers , type , & len );
1414+
1415+ if (value ) {
1416+ return estrndup (value , len );
1417+ }
1418+
1419+ return NULL ;
1420+ }
1421+
14031422static zend_string * get_http_body (php_stream * stream , int close , char * headers )
14041423{
14051424 zend_string * http_buf = NULL ;
0 commit comments