xref: /PHP-8.1/ext/oci8/tests/null_byte_1.phpt (revision 3e9b53f2)
1--TEST--
2Protect against null bytes in LOB filenames
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7if (PHP_MAJOR_VERSION < 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4))
8    die ("skip Test only valid for PHP 5.4 onwards");
9?>
10--INI--
11display_errors = On
12--FILE--
13<?php
14
15// See http://news.php.net/php.internals/50202
16//     http://svn.php.net/viewvc?view=revision&revision=311870
17
18require(__DIR__.'/connect.inc');
19
20// Run Test
21
22echo "Test 1: Import\n";
23
24$lob = oci_new_descriptor($c, OCI_D_LOB);
25try {
26    $lob->saveFile("/tmp/abc\0def");
27} catch (ValueError $e) {
28       echo $e->getMessage(), "\n";
29}
30
31echo "Test 2: Export\n";
32
33try {
34    $lob->export("/tmp/abc\0def");
35} catch (ValueError $e) {
36       echo $e->getMessage(), "\n";
37}
38
39?>
40--EXPECT--
41Test 1: Import
42OCILob::saveFile(): Argument #1 ($filename) must not contain any null bytes
43Test 2: Export
44OCILob::export(): Argument #1 ($filename) must not contain any null bytes
45