xref: /PHP-8.0/ext/pgsql/tests/bug72197.phpt (revision a555cc0b)
1--TEST--
2Bug #72197 pg_lo_create arbitrary read
3--SKIPIF--
4<?php include("skipif.inc"); ?>
5--FILE--
6<?php
7/* This shouldn't crash. */
8$var1=-32768;
9$var2="12";
10try {
11    pg_lo_create($var1, $var2);
12} catch (TypeError $e) {
13    echo $e->getMessage(), "\n";
14}
15
16/* This should work correctly. */
17include('config.inc');
18
19/* Check with explicit link. */
20$conn = pg_connect($conn_str);
21pg_query($conn, "BEGIN");
22$oid = pg_lo_create($conn);
23var_dump($oid);
24
25/* Check with default link */
26$oid = pg_lo_create();
27var_dump($oid);
28
29/* don't commit */
30pg_query($conn, "ROLLBACK");
31pg_close($conn);
32?>
33--EXPECTF--
34pg_lo_create(): supplied resource is not a valid PostgreSQL link resource%w
35int(%d)
36int(%d)
37