Skip to content

Commit 512abc2

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fixed bug phpGH-10270 Unable to return CURL_READFUNC_PAUSE in readfunc callback Fix phpGH-10672 (pg_lo_open segfaults in the strict_types mode)
2 parents f1818d7 + 91db3a1 commit 512abc2

File tree

6 files changed

+97
-1
lines changed

6 files changed

+97
-1
lines changed

NEWS

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PHP NEWS
1616

1717
- Curl:
1818
. Fixed deprecation warning at compile time. (Max Kellermann)
19+
. Fixed bug GH-10270 (Unable to return CURL_READFUNC_PAUSE in readfunc
20+
callback). (Pierrick Charron)
1921

2022
- Date:
2123
. Fix GH-10447 ('p' format specifier does not yield 'Z' for 00:00). (Derick)
@@ -56,6 +58,9 @@ PHP NEWS
5658
. Fixed bug #60994 (Reading a multibyte CLOB caps at 8192 chars).
5759
(Michael Voříšek)
5860

61+
- PGSQL:
62+
. Fix GH-10672 (pg_lo_open segfaults in the strict_types mode). (girgias)
63+
5964
- Phar:
6065
. Fix incorrect check in phar tar parsing. (nielsdos)
6166

ext/curl/interface.c

+2
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,8 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
811811
if (Z_TYPE(retval) == IS_STRING) {
812812
length = MIN((int) (size * nmemb), Z_STRLEN(retval));
813813
memcpy(data, Z_STRVAL(retval), length);
814+
} else if (Z_TYPE(retval) == IS_LONG) {
815+
length = Z_LVAL_P(&retval);
814816
}
815817
zval_ptr_dtor(&retval);
816818
}

ext/curl/tests/curl_pause_001.phpt

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--TEST--
2+
Test CURL_READFUNC_PAUSE and curl_pause()
3+
--EXTENSIONS--
4+
curl
5+
--FILE--
6+
<?php
7+
include 'server.inc';
8+
$host = curl_cli_server_start();
9+
10+
class Input {
11+
private static $RESPONSES = [
12+
'Foo bar ',
13+
CURL_READFUNC_PAUSE,
14+
'baz qux',
15+
null
16+
];
17+
private int $res = 0;
18+
public function __invoke($ch, $hReadHandle, $iMaxOut)
19+
{
20+
return self::$RESPONSES[$this->res++];
21+
}
22+
}
23+
24+
$inputHandle = fopen(__FILE__, 'r');
25+
26+
$ch = curl_init();
27+
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=input");
28+
curl_setopt($ch, CURLOPT_UPLOAD, 1);
29+
curl_setopt($ch, CURLOPT_READFUNCTION, new Input);
30+
curl_setopt($ch, CURLOPT_INFILE, $inputHandle);
31+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
32+
33+
$mh = curl_multi_init();
34+
curl_multi_add_handle($mh, $ch);
35+
do {
36+
$status = curl_multi_exec($mh, $active);
37+
curl_pause($ch, CURLPAUSE_CONT);
38+
if ($active) {
39+
usleep(100);
40+
curl_multi_select($mh);
41+
}
42+
} while ($active && $status == CURLM_OK);
43+
44+
echo curl_multi_getcontent($ch);
45+
?>
46+
--EXPECT--
47+
string(15) "Foo bar baz qux"

ext/curl/tests/responder/get.inc

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
case 'post':
55
var_dump($_POST);
66
break;
7+
case 'input':
8+
var_dump(file_get_contents('php://input'));
9+
break;
710
case 'getpost':
811
var_dump($_GET);
912
var_dump($_POST);

ext/pgsql/pgsql.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2364,7 +2364,7 @@ PHP_FUNCTION(pg_lo_open)
23642364
CHECK_PGSQL_LINK(link);
23652365
}
23662366
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
2367-
"Ols", &pgsql_link, pgsql_link_ce, &oid_long, &mode) == SUCCESS) {
2367+
"OlS", &pgsql_link, pgsql_link_ce, &oid_long, &mode) == SUCCESS) {
23682368
if (oid_long <= (zend_long)InvalidOid) {
23692369
zend_value_error("Invalid OID value passed");
23702370
RETURN_THROWS();

ext/pgsql/tests/gh10672.phpt

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
GH-10672 (pg_lo_open segfaults in the strict_types mode)
3+
--EXTENSIONS--
4+
pgsql
5+
--SKIPIF--
6+
<?php
7+
include("skipif.inc");
8+
?>
9+
--FILE--
10+
<?php
11+
declare(strict_types=1);
12+
13+
include "config.inc";
14+
15+
$db = pg_connect($conn_str);
16+
pg_query($db, "DROP TABLE IF EXISTS gh10672");
17+
pg_query($db, "CREATE TABLE gh10672 (bar text);");
18+
19+
// Begin a transaction
20+
pg_query($db, 'BEGIN');
21+
22+
// Create an empty large object
23+
$oid = pg_lo_create($db);
24+
25+
if ($oid === false) {
26+
die(pg_last_error($db));
27+
}
28+
29+
// Open the large object for writing
30+
$lob = pg_lo_open($db, $oid, 'w');
31+
32+
if ($oid === false) {
33+
die(pg_last_error($db));
34+
}
35+
36+
echo 'The large object has been opened successfully.', PHP_EOL;
37+
?>
38+
--EXPECT--
39+
The large object has been opened successfully.

0 commit comments

Comments
 (0)