Skip to content

Commit d68cd18

Browse files
lacatoiredevnexen
authored andcommitted
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
1 parent 6c0388f commit d68cd18

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎ext/pgsql/pgsql.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,7 +2785,7 @@ PHP_FUNCTION(pg_lo_read)
27852785
CHECK_PGSQL_LOB(pgsql);
27862786

27872787
if (buffer_length < 0) {
2788-
zend_argument_value_error(2, "must be greater or equal than 0");
2788+
zend_argument_value_error(2, "must be greater than or equal to 0");
27892789
RETURN_THROWS();
27902790
}
27912791

@@ -2825,7 +2825,7 @@ PHP_FUNCTION(pg_lo_write)
28252825
RETURN_THROWS();
28262826
}
28272827
if (z_len > (zend_long)ZSTR_LEN(str)) {
2828-
zend_argument_value_error(3, "must be less than or equal to the length of argument #2 ($buf)");
2828+
zend_argument_value_error(3, "must be less than or equal to the length of argument #2 ($data)");
28292829
RETURN_THROWS();
28302830
}
28312831
len = z_len;

‎ext/pgsql/tests/pg_lo_write_null_bytes.phpt‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ pg_lo_write($handle, "x\0y");
3636
pg_lo_close($handle);
3737
$handle = pg_lo_open($db, $oid, "r");
3838
var_dump(bin2hex(pg_lo_read($handle)));
39+
try {
40+
pg_lo_read($handle, -1);
41+
} catch (Throwable $e) {
42+
echo $e::class, ": ", $e->getMessage(), "\n";
43+
}
3944
pg_lo_close($handle);
4045
pg_exec($db, "ROLLBACK");
4146
?>
@@ -45,5 +50,6 @@ int(4)
4550
int(2)
4651
int(0)
4752
ValueError: pg_lo_write(): Argument #3 ($length) must be greater than or equal to 0
48-
ValueError: pg_lo_write(): Argument #3 ($length) must be less than or equal to the length of argument #2 ($buf)
53+
ValueError: pg_lo_write(): Argument #3 ($length) must be less than or equal to the length of argument #2 ($data)
4954
string(6) "780079"
55+
ValueError: pg_lo_read(): Argument #2 ($length) must be greater than or equal to 0

0 commit comments

Comments
 (0)