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 ;
@@ -968,8 +970,9 @@ int make_http_soap_request(zval *this_ptr,
968
970
we shouldn't be changing urls so path doesn't
969
971
matter too much
970
972
*/
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 ))) {
973
976
char * cookie ;
974
977
char * eqpos , * sempos ;
975
978
zval * cookies ;
@@ -981,7 +984,7 @@ int make_http_soap_request(zval *this_ptr,
981
984
cookies = zend_hash_str_update (Z_OBJPROP_P (this_ptr ), "_cookies" , sizeof ("_cookies" )- 1 , & tmp_cookies );
982
985
}
983
986
984
- cookie = get_http_header_value (cookie_itt ,"Set-Cookie: " );
987
+ cookie = estrndup (cookie_itt , cookie_len );
985
988
986
989
eqpos = strstr (cookie , "=" );
987
990
sempos = strstr (cookie , ";" );
@@ -1039,7 +1042,7 @@ int make_http_soap_request(zval *this_ptr,
1039
1042
smart_str_free (& name );
1040
1043
}
1041
1044
1042
- cookie_itt = strstr ( cookie_itt + sizeof ( "Set-Cookie: " ), "Set-Cookie: " ) ;
1045
+ cookie_itt = cookie_itt + cookie_len ;
1043
1046
efree (cookie );
1044
1047
}
1045
1048
@@ -1357,7 +1360,7 @@ int make_http_soap_request(zval *this_ptr,
1357
1360
return TRUE;
1358
1361
}
1359
1362
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 )
1361
1364
{
1362
1365
char * pos , * tmp = NULL ;
1363
1366
int typelen , headerslen ;
@@ -1394,7 +1397,9 @@ static char *get_http_header_value(char *headers, char *type)
1394
1397
eol -- ;
1395
1398
}
1396
1399
}
1397
- return estrndup (tmp , eol - tmp );
1400
+
1401
+ * len = eol - tmp ;
1402
+ return tmp ;
1398
1403
}
1399
1404
1400
1405
/* find next line */
@@ -1408,6 +1413,20 @@ static char *get_http_header_value(char *headers, char *type)
1408
1413
return NULL ;
1409
1414
}
1410
1415
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
+
1411
1430
static zend_string * get_http_body (php_stream * stream , int close , char * headers )
1412
1431
{
1413
1432
zend_string * http_buf = NULL ;
0 commit comments