mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fixed bug GH-10270 Unable to return CURL_READFUNC_PAUSE in readfunc callback Fix GH-10672 (pg_lo_open segfaults in the strict_types mode)
This commit is contained in:
commit
51b70e4414
5 changed files with 92 additions and 1 deletions
|
@ -811,6 +811,8 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
|
|||
if (Z_TYPE(retval) == IS_STRING) {
|
||||
length = MIN((int) (size * nmemb), Z_STRLEN(retval));
|
||||
memcpy(data, Z_STRVAL(retval), length);
|
||||
} else if (Z_TYPE(retval) == IS_LONG) {
|
||||
length = Z_LVAL_P(&retval);
|
||||
}
|
||||
zval_ptr_dtor(&retval);
|
||||
}
|
||||
|
|
47
ext/curl/tests/curl_pause_001.phpt
Normal file
47
ext/curl/tests/curl_pause_001.phpt
Normal file
|
@ -0,0 +1,47 @@
|
|||
--TEST--
|
||||
Test CURL_READFUNC_PAUSE and curl_pause()
|
||||
--EXTENSIONS--
|
||||
curl
|
||||
--FILE--
|
||||
<?php
|
||||
include 'server.inc';
|
||||
$host = curl_cli_server_start();
|
||||
|
||||
class Input {
|
||||
private static $RESPONSES = [
|
||||
'Foo bar ',
|
||||
CURL_READFUNC_PAUSE,
|
||||
'baz qux',
|
||||
null
|
||||
];
|
||||
private int $res = 0;
|
||||
public function __invoke($ch, $hReadHandle, $iMaxOut)
|
||||
{
|
||||
return self::$RESPONSES[$this->res++];
|
||||
}
|
||||
}
|
||||
|
||||
$inputHandle = fopen(__FILE__, 'r');
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=input");
|
||||
curl_setopt($ch, CURLOPT_UPLOAD, 1);
|
||||
curl_setopt($ch, CURLOPT_READFUNCTION, new Input);
|
||||
curl_setopt($ch, CURLOPT_INFILE, $inputHandle);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
$mh = curl_multi_init();
|
||||
curl_multi_add_handle($mh, $ch);
|
||||
do {
|
||||
$status = curl_multi_exec($mh, $active);
|
||||
curl_pause($ch, CURLPAUSE_CONT);
|
||||
if ($active) {
|
||||
usleep(100);
|
||||
curl_multi_select($mh);
|
||||
}
|
||||
} while ($active && $status == CURLM_OK);
|
||||
|
||||
echo curl_multi_getcontent($ch);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(15) "Foo bar baz qux"
|
|
@ -4,6 +4,9 @@
|
|||
case 'post':
|
||||
var_dump($_POST);
|
||||
break;
|
||||
case 'input':
|
||||
var_dump(file_get_contents('php://input'));
|
||||
break;
|
||||
case 'getpost':
|
||||
var_dump($_GET);
|
||||
var_dump($_POST);
|
||||
|
|
|
@ -2338,7 +2338,7 @@ PHP_FUNCTION(pg_lo_open)
|
|||
CHECK_PGSQL_LINK(link);
|
||||
}
|
||||
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
|
||||
"Ols", &pgsql_link, pgsql_link_ce, &oid_long, &mode) == SUCCESS) {
|
||||
"OlS", &pgsql_link, pgsql_link_ce, &oid_long, &mode) == SUCCESS) {
|
||||
if (oid_long <= (zend_long)InvalidOid) {
|
||||
zend_value_error("Invalid OID value passed");
|
||||
RETURN_THROWS();
|
||||
|
|
39
ext/pgsql/tests/gh10672.phpt
Normal file
39
ext/pgsql/tests/gh10672.phpt
Normal file
|
@ -0,0 +1,39 @@
|
|||
--TEST--
|
||||
GH-10672 (pg_lo_open segfaults in the strict_types mode)
|
||||
--EXTENSIONS--
|
||||
pgsql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include("skipif.inc");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
include "config.inc";
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
pg_query($db, "DROP TABLE IF EXISTS gh10672");
|
||||
pg_query($db, "CREATE TABLE gh10672 (bar text);");
|
||||
|
||||
// Begin a transaction
|
||||
pg_query($db, 'BEGIN');
|
||||
|
||||
// Create an empty large object
|
||||
$oid = pg_lo_create($db);
|
||||
|
||||
if ($oid === false) {
|
||||
die(pg_last_error($db));
|
||||
}
|
||||
|
||||
// Open the large object for writing
|
||||
$lob = pg_lo_open($db, $oid, 'w');
|
||||
|
||||
if ($oid === false) {
|
||||
die(pg_last_error($db));
|
||||
}
|
||||
|
||||
echo 'The large object has been opened successfully.', PHP_EOL;
|
||||
?>
|
||||
--EXPECT--
|
||||
The large object has been opened successfully.
|
Loading…
Add table
Add a link
Reference in a new issue