[php-src] master: ext/pgsql: fix the wrong names in the pg_lo_write() and pg_lo_read() errors

From: Date: Thu, 12 Nov 2026 18:02:03 +0000
Subject: [php-src] master: ext/pgsql: fix the wrong names in the pg_lo_write() and pg_lo_read() errors
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143646@lists.php.net to get a copy of this message
Author: lacatoire (lacatoire) Committer: David Carlier (devnexen) Date: 2026-11-12T18:01:39Z Commit: https://github.com/php/php-src/commit/d68cd18ceb7afa5107764e39b899bd785bd89b1e Raw diff: https://github.com/php/php-src/commit/d68cd18ceb7afa5107764e39b899bd785bd89b1e.diff ext/pgsql: fix the wrong names in the pg_lo_write() and pg_lo_read() errors pg_lo_write() referred to a nonexistent $buf parameter; it is $data. pg_lo_read() was the only check worded "greater or equal than". Close GH-25409 Changed paths: M ext/pgsql/pgsql.c M ext/pgsql/tests/pg_lo_write_null_bytes.phpt Diff: diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 2eb2d6b306e7..64d3b61d18df 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2785,7 +2785,7 @@ PHP_FUNCTION(pg_lo_read) CHECK_PGSQL_LOB(pgsql); if (buffer_length < 0) { - zend_argument_value_error(2, "must be greater or equal than 0"); + zend_argument_value_error(2, "must be greater than or equal to 0"); RETURN_THROWS(); } @@ -2825,7 +2825,7 @@ PHP_FUNCTION(pg_lo_write) RETURN_THROWS(); } if (z_len > (zend_long)ZSTR_LEN(str)) { - zend_argument_value_error(3, "must be less than or equal to the length of argument #2 ($buf)"); + zend_argument_value_error(3, "must be less than or equal to the length of argument #2 ($data)"); RETURN_THROWS(); } len = z_len; diff --git a/ext/pgsql/tests/pg_lo_write_null_bytes.phpt b/ext/pgsql/tests/pg_lo_write_null_bytes.phpt index 44073692a182..681669895b89 100644 --- a/ext/pgsql/tests/pg_lo_write_null_bytes.phpt +++ b/ext/pgsql/tests/pg_lo_write_null_bytes.phpt @@ -36,6 +36,11 @@ pg_lo_write($handle, "x\0y"); pg_lo_close($handle); $handle = pg_lo_open($db, $oid, "r"); var_dump(bin2hex(pg_lo_read($handle))); +try { + pg_lo_read($handle, -1); +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage(), "\n"; +} pg_lo_close($handle); pg_exec($db, "ROLLBACK"); ?> @@ -45,5 +50,6 @@ int(4) int(2) int(0) ValueError: pg_lo_write(): Argument #3 ($length) must be greater than or equal to 0 -ValueError: pg_lo_write(): Argument #3 ($length) must be less than or equal to the length of argument #2 ($buf) +ValueError: pg_lo_write(): Argument #3 ($length) must be less than or equal to the length of argument #2 ($data) string(6) "780079" +ValueError: pg_lo_read(): Argument #2 ($length) must be greater than or equal to 0

« previous php.cvs (#143646) next »