xref: /PHP-8.3/ext/oci8/tests/null_byte_3.phpt (revision a53e5617)
1--TEST--
2Null bytes in SQL statements
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--INI--
10display_errors = On
11error_reporting = E_WARNING
12--FILE--
13<?php
14
15require __DIR__.'/connect.inc';
16
17// Run Test
18
19echo "Test 1: Invalid use of a null byte\n";
20
21$s = oci_parse($c, "select * from du\0al");
22oci_execute($s);
23
24echo "Test 2: Using a null byte in a bind variable value causing WHERE clause to fail\n";
25
26$s = oci_parse($c, "select * from dual where :bv = 'abc'");
27$bv = 'abc\0abc';
28oci_bind_by_name($s, ":bv", $bv);
29oci_execute($s);
30oci_fetch_all($s, $res);
31var_dump($res);
32
33?>
34--EXPECTF--
35Test 1: Invalid use of a null byte
36
37Warning: oci_execute(): ORA-00942: %s in %snull_byte_3.php on line %d
38Test 2: Using a null byte in a bind variable value causing WHERE clause to fail
39array(1) {
40  ["DUMMY"]=>
41  array(0) {
42  }
43}
44