21
21
#include "ext/standard/md5.h"
22
22
#include "ext/standard/php_random.h"
23
23
24
+ static char * get_http_header_value_nodup (char * headers , char * type , size_t * len );
24
25
static char * get_http_header_value (char * headers , char * type );
25
26
static zend_string * get_http_body (php_stream * socketd , int close , char * headers );
26
27
static zend_string * get_http_headers (php_stream * socketd );
@@ -348,6 +349,7 @@ int make_http_soap_request(zval *this_ptr,
348
349
int use_ssl ;
349
350
zend_string * http_body ;
350
351
char * content_type , * http_version , * cookie_itt ;
352
+ size_t cookie_len ;
351
353
int http_close ;
352
354
zend_string * http_headers ;
353
355
char * connection ;
@@ -958,8 +960,9 @@ int make_http_soap_request(zval *this_ptr,
958
960
we shouldn't be changing urls so path doesn't
959
961
matter too much
960
962
*/
961
- cookie_itt = strstr (ZSTR_VAL (http_headers ), "Set-Cookie: " );
962
- while (cookie_itt ) {
963
+ cookie_itt = ZSTR_VAL (http_headers );
964
+
965
+ while ((cookie_itt = get_http_header_value_nodup (cookie_itt , "Set-Cookie: " , & cookie_len ))) {
963
966
char * cookie ;
964
967
char * eqpos , * sempos ;
965
968
zval * cookies ;
@@ -971,7 +974,7 @@ int make_http_soap_request(zval *this_ptr,
971
974
cookies = zend_hash_str_update (Z_OBJPROP_P (this_ptr ), "_cookies" , sizeof ("_cookies" )- 1 , & tmp_cookies );
972
975
}
973
976
974
- cookie = get_http_header_value (cookie_itt ,"Set-Cookie: " );
977
+ cookie = estrndup (cookie_itt , cookie_len );
975
978
976
979
eqpos = strstr (cookie , "=" );
977
980
sempos = strstr (cookie , ";" );
@@ -1029,7 +1032,7 @@ int make_http_soap_request(zval *this_ptr,
1029
1032
smart_str_free (& name );
1030
1033
}
1031
1034
1032
- cookie_itt = strstr ( cookie_itt + sizeof ( "Set-Cookie: " ), "Set-Cookie: " ) ;
1035
+ cookie_itt = cookie_itt + cookie_len ;
1033
1036
efree (cookie );
1034
1037
}
1035
1038
@@ -1347,7 +1350,7 @@ int make_http_soap_request(zval *this_ptr,
1347
1350
return TRUE;
1348
1351
}
1349
1352
1350
- static char * get_http_header_value (char * headers , char * type )
1353
+ static char * get_http_header_value_nodup (char * headers , char * type , size_t * len )
1351
1354
{
1352
1355
char * pos , * tmp = NULL ;
1353
1356
int typelen , headerslen ;
@@ -1384,7 +1387,9 @@ static char *get_http_header_value(char *headers, char *type)
1384
1387
eol -- ;
1385
1388
}
1386
1389
}
1387
- return estrndup (tmp , eol - tmp );
1390
+
1391
+ * len = eol - tmp ;
1392
+ return tmp ;
1388
1393
}
1389
1394
1390
1395
/* find next line */
@@ -1398,6 +1403,20 @@ static char *get_http_header_value(char *headers, char *type)
1398
1403
return NULL ;
1399
1404
}
1400
1405
1406
+ static char * get_http_header_value (char * headers , char * type )
1407
+ {
1408
+ size_t len ;
1409
+ char * value ;
1410
+
1411
+ value = get_http_header_value_nodup (headers , type , & len );
1412
+
1413
+ if (value ) {
1414
+ return estrndup (value , len );
1415
+ }
1416
+
1417
+ return NULL ;
1418
+ }
1419
+
1401
1420
static zend_string * get_http_body (php_stream * stream , int close , char * headers )
1402
1421
{
1403
1422
zend_string * http_buf = NULL ;
0 commit comments