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