23
23
#include "ext/standard/md5.h"
24
24
#include "ext/standard/php_random.h"
25
25
26
+ static char * get_http_header_value_nodup (char * headers , char * type , size_t * len );
26
27
static char * get_http_header_value (char * headers , char * type );
27
28
static zend_string * get_http_body (php_stream * socketd , int close , char * headers );
28
29
static zend_string * get_http_headers (php_stream * socketd );
@@ -350,6 +351,7 @@ int make_http_soap_request(zval *this_ptr,
350
351
int use_ssl ;
351
352
zend_string * http_body ;
352
353
char * content_type , * http_version , * cookie_itt ;
354
+ size_t cookie_len ;
353
355
int http_close ;
354
356
zend_string * http_headers ;
355
357
char * connection ;
@@ -960,8 +962,9 @@ int make_http_soap_request(zval *this_ptr,
960
962
we shouldn't be changing urls so path doesn't
961
963
matter too much
962
964
*/
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 ))) {
965
968
char * cookie ;
966
969
char * eqpos , * sempos ;
967
970
zval * cookies ;
@@ -973,7 +976,7 @@ int make_http_soap_request(zval *this_ptr,
973
976
cookies = zend_hash_str_update (Z_OBJPROP_P (this_ptr ), "_cookies" , sizeof ("_cookies" )- 1 , & tmp_cookies );
974
977
}
975
978
976
- cookie = get_http_header_value (cookie_itt ,"Set-Cookie: " );
979
+ cookie = estrndup (cookie_itt , cookie_len );
977
980
978
981
eqpos = strstr (cookie , "=" );
979
982
sempos = strstr (cookie , ";" );
@@ -1031,7 +1034,7 @@ int make_http_soap_request(zval *this_ptr,
1031
1034
smart_str_free (& name );
1032
1035
}
1033
1036
1034
- cookie_itt = strstr ( cookie_itt + sizeof ( "Set-Cookie: " ), "Set-Cookie: " ) ;
1037
+ cookie_itt = cookie_itt + cookie_len ;
1035
1038
efree (cookie );
1036
1039
}
1037
1040
@@ -1349,7 +1352,7 @@ int make_http_soap_request(zval *this_ptr,
1349
1352
return TRUE;
1350
1353
}
1351
1354
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 )
1353
1356
{
1354
1357
char * pos , * tmp = NULL ;
1355
1358
int typelen , headerslen ;
@@ -1386,7 +1389,9 @@ static char *get_http_header_value(char *headers, char *type)
1386
1389
eol -- ;
1387
1390
}
1388
1391
}
1389
- return estrndup (tmp , eol - tmp );
1392
+
1393
+ * len = eol - tmp ;
1394
+ return tmp ;
1390
1395
}
1391
1396
1392
1397
/* find next line */
@@ -1400,6 +1405,20 @@ static char *get_http_header_value(char *headers, char *type)
1400
1405
return NULL ;
1401
1406
}
1402
1407
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
+
1403
1422
static zend_string * get_http_body (php_stream * stream , int close , char * headers )
1404
1423
{
1405
1424
zend_string * http_buf = NULL ;
0 commit comments