Skip to content
Merged
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
9 changes: 9 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ PHP NEWS
class constants via OBJ->prop = $val). (Khaled Alam)
. Reverted GH-22833, which attempted to fix bug GH-18985. (ilutov)

- Curl:
. Set content length using CURLOPT_POSTFIELDSIZE_LARGE instead of
CURLOPT_POSTFIELDSIZE. This makes it possible to post strings larger than
2GB on some platforms, e.g. Windows. (Sjoerd Langkemper)

- DOM:
. Fixed bug GH-22624 (use-after-free via DOMNameSpaceNode after
DOMDocument::xinclude()). (David Carlier)

- PDO_PGSQL:
. Fixed several lazy fetch (PDO::ATTR_PREFETCH => 0) defects: an infinite
loop when cleaning up a fetch left in a COPY, a use-after-free when a
Expand Down
4 changes: 2 additions & 2 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2178,15 +2178,15 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
/* no need to build the mime structure for empty hashtables;
also works around https://github.com/curl/curl/issues/6455 */
curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, "");
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, 0L);
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t) 0);
} else {
return build_mime_structure_from_hash(ch, zvalue);
}
} else {
zend_string *tmp_str;
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
/* with curl 7.17.0 and later, we can use COPYPOSTFIELDS, but we have to provide size before */
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str));
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t) ZSTR_LEN(str));
error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, ZSTR_VAL(str));
zend_tmp_string_release(tmp_str);
}
Expand Down
30 changes: 30 additions & 0 deletions ext/curl/tests/curl_post_large_string.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
CURL post data larger than 2GB (to test CURLOPT_POSTFIELDSIZE_LARGE)
--INI--
memory_limit=3G
--SKIPIF--
<?php
if (!getenv('RUN_RESOURCE_HEAVY_TESTS')) die('skip resource-heavy test');
if (PHP_INT_SIZE < 8) die('skip 64-bit only');
include 'skipif-nocaddy.inc';
?>
--EXTENSIONS--
curl
--FILE--
<?php
$size = 2 ** 31 + 100; // a little bit more than a signed 32-bit int
$data = str_repeat('a', $size);

$ch = curl_init("https://localhost/show_upload_size");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
]);

$response = curl_exec($ch);
var_dump($response);

?>
--EXPECT--
string(28) "Content-length: =2147483748="
19 changes: 17 additions & 2 deletions ext/dom/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,21 @@ zend_result dom_node_node_type_read(dom_object *obj, zval *retval)

/* }}} */

static xmlNodePtr dom_node_get_parent(dom_object *obj, xmlNodePtr nodep)
{
if (nodep->type == XML_NAMESPACE_DECL) {
dom_object_namespace_node *ns = php_dom_namespace_node_obj_from_obj(&obj->std);
return ns->parent_intern ? dom_object_get_node(ns->parent_intern) : NULL;
}
return nodep->parent;
}


static zend_result dom_node_parent_get(dom_object *obj, zval *retval, bool only_element)
{
DOM_PROP_NODE(xmlNodePtr, nodep, obj);

xmlNodePtr nodeparent = nodep->parent;
xmlNodePtr nodeparent = dom_node_get_parent(obj, nodep);
if (!nodeparent || (only_element && nodeparent->type != XML_ELEMENT_NODE)) {
ZVAL_NULL(retval);
return SUCCESS;
Expand Down Expand Up @@ -457,7 +467,12 @@ URL: https://dom.spec.whatwg.org/#dom-node-isconnected
zend_result dom_node_is_connected_read(dom_object *obj, zval *retval)
{
DOM_PROP_NODE(xmlNodePtr, nodep, obj);
ZVAL_BOOL(retval, php_dom_is_node_connected(nodep));
if (nodep->type == XML_NAMESPACE_DECL) {
xmlNodePtr parent = dom_node_get_parent(obj, nodep);
ZVAL_BOOL(retval, parent && php_dom_is_node_connected(parent));
} else {
ZVAL_BOOL(retval, php_dom_is_node_connected(nodep));
}
return SUCCESS;
}
/* }}} */
Expand Down
41 changes: 41 additions & 0 deletions ext/dom/tests/gh22624.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--TEST--
GH-22624 (Use-after-free via DOMNameSpaceNode after DOMDocument::xinclude())
--CREDITS--
ExPatch-LLC
--EXTENSIONS--
dom
--SKIPIF--
<?php
if (!function_exists('libxml_set_external_entity_loader')) die('skip xinclude not available');
?>
--FILE--
<?php
$included = __DIR__ . '/gh22624_included.xml';
file_put_contents($included, '<?xml version="1.0"?><included/>');
$href = 'file:///' . ltrim(str_replace('\\', '/', $included), '/');

$doc = new DOMDocument();
$doc->loadXML('<?xml version="1.0"?>
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="' . $href . '" xmlns:local="urn:test"/>
</root>');

$xpath = new DOMXPath($doc);
$xpath->registerNamespace('xi', 'http://www.w3.org/2001/XInclude');
$xi = $xpath->query('//xi:include')->item(0);
$ns = $xpath->query('namespace::local', $xi)->item(0); // DOMNameSpaceNode

$doc->xinclude(); // frees the xi:include element

var_dump($ns->parentNode);
var_dump($ns->parentElement);
var_dump($ns->isConnected);
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/gh22624_included.xml');
?>
--EXPECT--
NULL
NULL
bool(false)
4 changes: 2 additions & 2 deletions ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -3319,9 +3319,9 @@ static PHP_MINFO_FUNCTION(zip)
php_info_print_table_row(2, "AES-128 encryption",
zip_encryption_method_supported(ZIP_EM_AES_128, 1) ? "Yes" : "No");
php_info_print_table_row(2, "AES-192 encryption",
zip_encryption_method_supported(ZIP_EM_AES_128, 1) ? "Yes" : "No");
zip_encryption_method_supported(ZIP_EM_AES_192, 1) ? "Yes" : "No");
php_info_print_table_row(2, "AES-256 encryption",
zip_encryption_method_supported(ZIP_EM_AES_128, 1) ? "Yes" : "No");
zip_encryption_method_supported(ZIP_EM_AES_256, 1) ? "Yes" : "No");
#endif

php_info_print_table_end();
Expand Down