Skip to content

Fix bug #61525: SOAP functions require at least one space after HTTP header colon #15793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions ext/soap/php_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ int make_http_soap_request(zval *this_ptr,
*/
cookie_itt = ZSTR_VAL(http_headers);

while ((cookie_itt = get_http_header_value_nodup(cookie_itt, "Set-Cookie: ", &cookie_len))) {
while ((cookie_itt = get_http_header_value_nodup(cookie_itt, "Set-Cookie:", &cookie_len))) {
zval *cookies = Z_CLIENT_COOKIES_P(this_ptr);
SEPARATE_ARRAY(cookies);

Expand Down Expand Up @@ -1049,7 +1049,7 @@ int make_http_soap_request(zval *this_ptr,
if (http_1_1) {
http_close = FALSE;
if (use_proxy && !use_ssl) {
connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection: ");
connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection:");
if (connection) {
if (strncasecmp(connection, "close", sizeof("close")-1) == 0) {
http_close = TRUE;
Expand All @@ -1058,7 +1058,7 @@ int make_http_soap_request(zval *this_ptr,
}
}
if (http_close == FALSE) {
connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection: ");
connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection:");
if (connection) {
if (strncasecmp(connection, "close", sizeof("close")-1) == 0) {
http_close = TRUE;
Expand All @@ -1069,7 +1069,7 @@ int make_http_soap_request(zval *this_ptr,
} else {
http_close = TRUE;
if (use_proxy && !use_ssl) {
connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection: ");
connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection:");
if (connection) {
if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) {
http_close = FALSE;
Expand All @@ -1078,7 +1078,7 @@ int make_http_soap_request(zval *this_ptr,
}
}
if (http_close == TRUE) {
connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection: ");
connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection:");
if (connection) {
if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) {
http_close = FALSE;
Expand Down Expand Up @@ -1121,7 +1121,7 @@ int make_http_soap_request(zval *this_ptr,
if (http_status >= 300 && http_status < 400) {
char *loc;

if ((loc = get_http_header_value(ZSTR_VAL(http_headers), "Location: ")) != NULL) {
if ((loc = get_http_header_value(ZSTR_VAL(http_headers), "Location:")) != NULL) {
php_url *new_url = php_url_parse(loc);

if (new_url != NULL) {
Expand Down Expand Up @@ -1170,7 +1170,7 @@ int make_http_soap_request(zval *this_ptr,
zval *digest = Z_CLIENT_DIGEST_P(this_ptr);
zval *login = Z_CLIENT_LOGIN_P(this_ptr);
zval *password = Z_CLIENT_PASSWORD_P(this_ptr);
char *auth = get_http_header_value(ZSTR_VAL(http_headers), "WWW-Authenticate: ");
char *auth = get_http_header_value(ZSTR_VAL(http_headers), "WWW-Authenticate:");
if (auth && strstr(auth, "Digest") == auth && Z_TYPE_P(digest) != IS_ARRAY
&& Z_TYPE_P(login) == IS_STRING && Z_TYPE_P(password) == IS_STRING) {
char *s;
Expand Down Expand Up @@ -1240,7 +1240,7 @@ int make_http_soap_request(zval *this_ptr,
smart_str_free(&soap_headers_z);

/* Check and see if the server even sent a xml document */
content_type = get_http_header_value(ZSTR_VAL(http_headers), "Content-Type: ");
content_type = get_http_header_value(ZSTR_VAL(http_headers), "Content-Type:");
if (content_type) {
char *pos = NULL;
int cmplen;
Expand Down Expand Up @@ -1270,7 +1270,7 @@ int make_http_soap_request(zval *this_ptr,
}

/* Decompress response */
content_encoding = get_http_header_value(ZSTR_VAL(http_headers), "Content-Encoding: ");
content_encoding = get_http_header_value(ZSTR_VAL(http_headers), "Content-Encoding:");
if (content_encoding) {
zval func;
zval retval;
Expand Down Expand Up @@ -1430,18 +1430,18 @@ static zend_string* get_http_body(php_stream *stream, int close, char *headers)
int header_close = close, header_chunked = 0, header_length = 0, http_buf_size = 0;

if (!close) {
header = get_http_header_value(headers, "Connection: ");
header = get_http_header_value(headers, "Connection:");
if (header) {
if(!strncasecmp(header, "close", sizeof("close")-1)) header_close = 1;
efree(header);
}
}
header = get_http_header_value(headers, "Transfer-Encoding: ");
header = get_http_header_value(headers, "Transfer-Encoding:");
if (header) {
if(!strncasecmp(header, "chunked", sizeof("chunked")-1)) header_chunked = 1;
efree(header);
}
header = get_http_header_value(headers, "Content-Length: ");
header = get_http_header_value(headers, "Content-Length:");
if (header) {
header_length = atoi(header);
efree(header);
Expand Down
33 changes: 33 additions & 0 deletions ext/soap/tests/bugs/bug61525.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--TEST--
Bug #61525 (SOAP functions require at least one space after HTTP header colon)
--EXTENSIONS--
soap
--SKIPIF--
<?php
if (@!include __DIR__."/../../../standard/tests/http/server.inc") die('skip server.inc not available');
http_server_skipif();
?>
--FILE--
<?php
require __DIR__."/../../../standard/tests/http/server.inc";

$response = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:AddResponse>
<return xsi:type="xsd:int">7</return>
</ns1:AddResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML;

$length = strlen($response);
$server_response = "data://text/xml;base64," . base64_encode("HTTP/1.1 200 OK\r\nConnection:close\r\nContent-Length:$length\r\n\r\n$response");
['pid' => $pid, 'uri' => $uri] = http_server([$server_response]);
$client = new SoapClient(NULL, ['location' => $uri, 'uri' => $uri]);
var_dump($client->Add(3, 4));
http_server_kill($pid);
?>
--EXPECT--
int(7)
Loading