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