Fix GH-10672 (pg_lo_open segfaults in the strict_types mode)

We need to use the proper ZPP qualifier for zend_string

Closes GH-10677
This commit is contained in:
George Peter Banyard 2023-02-23 05:35:39 +00:00
parent 8d1c0a1403
commit 5f357f341d
No known key found for this signature in database
GPG Key ID: 3306078E3194AEBD
3 changed files with 43 additions and 1 deletions

3
NEWS
View File

@ -50,6 +50,9 @@ PHP NEWS
. Fixed bug #60994 (Reading a multibyte CLOB caps at 8192 chars).
(Michael Voříšek)
- PGSQL:
. Fix GH-10672 (pg_lo_open segfaults in the strict_types mode). (girgias)
- Phar:
. Fix incorrect check in phar tar parsing. (nielsdos)

View File

@ -2464,7 +2464,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();

View 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.