Skip to content

Commit e55a658

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: ext/soap: Compare Set-Cookie header case-insensitively
2 parents 801cf66 + f0d2efb commit e55a658

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

ext/soap/php_http.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "ext/standard/md5.h"
2222
#include "ext/standard/php_random.h"
2323

24+
static char *get_http_header_value_nodup(char *headers, char *type, size_t *len);
2425
static char *get_http_header_value(char *headers, char *type);
2526
static zend_string *get_http_body(php_stream *socketd, int close, char *headers);
2627
static zend_string *get_http_headers(php_stream *socketd);
@@ -348,6 +349,7 @@ int make_http_soap_request(zval *this_ptr,
348349
int use_ssl;
349350
zend_string *http_body;
350351
char *content_type, *http_version, *cookie_itt;
352+
size_t cookie_len;
351353
int http_close;
352354
zend_string *http_headers;
353355
char *connection;
@@ -958,8 +960,9 @@ int make_http_soap_request(zval *this_ptr,
958960
we shouldn't be changing urls so path doesn't
959961
matter too much
960962
*/
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))) {
963966
char *cookie;
964967
char *eqpos, *sempos;
965968
zval *cookies;
@@ -971,7 +974,7 @@ int make_http_soap_request(zval *this_ptr,
971974
cookies = zend_hash_str_update(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies")-1, &tmp_cookies);
972975
}
973976

974-
cookie = get_http_header_value(cookie_itt,"Set-Cookie: ");
977+
cookie = estrndup(cookie_itt, cookie_len);
975978

976979
eqpos = strstr(cookie, "=");
977980
sempos = strstr(cookie, ";");
@@ -1029,7 +1032,7 @@ int make_http_soap_request(zval *this_ptr,
10291032
smart_str_free(&name);
10301033
}
10311034

1032-
cookie_itt = strstr(cookie_itt + sizeof("Set-Cookie: "), "Set-Cookie: ");
1035+
cookie_itt = cookie_itt + cookie_len;
10331036
efree(cookie);
10341037
}
10351038

@@ -1347,7 +1350,7 @@ int make_http_soap_request(zval *this_ptr,
13471350
return TRUE;
13481351
}
13491352

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)
13511354
{
13521355
char *pos, *tmp = NULL;
13531356
int typelen, headerslen;
@@ -1384,7 +1387,9 @@ static char *get_http_header_value(char *headers, char *type)
13841387
eol--;
13851388
}
13861389
}
1387-
return estrndup(tmp, eol - tmp);
1390+
1391+
*len = eol - tmp;
1392+
return tmp;
13881393
}
13891394

13901395
/* find next line */
@@ -1398,6 +1403,20 @@ static char *get_http_header_value(char *headers, char *type)
13981403
return NULL;
13991404
}
14001405

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+
14011420
static zend_string* get_http_body(php_stream *stream, int close, char *headers)
14021421
{
14031422
zend_string *http_buf = NULL;

0 commit comments

Comments
 (0)