File: sqlite3_21_security.phpt

package info (click to toggle)
php5 5.6.33%2Bdfsg-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 157,872 kB
  • sloc: ansic: 756,065; php: 22,030; sh: 12,311; cpp: 8,771; xml: 6,179; yacc: 1,564; exp: 1,514; makefile: 1,467; pascal: 1,147; awk: 538; perl: 315; sql: 22
file content (41 lines) | stat: -rw-r--r-- 946 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--TEST--
SQLite3 open_basedir checks
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--INI--
open_basedir=.
--FILE--
<?php
chdir(__DIR__);

$directory = dirname(__FILE__) . '/';
$file = uniqid() . '.db';

echo "Within test directory\n";
$db = new SQLite3($directory . $file);
var_dump($db);
var_dump($db->close());
unlink($directory . $file);

echo "Above test directory\n";
try {
	$db = new SQLite3('../bad' . $file);
} catch (Exception $e) {
	echo $e . "\n";
}

echo "Done\n";
?>
--EXPECTF--
Within test directory
object(SQLite3)#%d (0) {
}
bool(true)
Above test directory

Warning: SQLite3::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %ssqlite3_21_security.php on line %d
exception 'Exception' with message 'open_basedir prohibits opening %s' in %ssqlite3_21_security.php:%d
Stack trace:
#0 %ssqlite3_21_security.php(%d): SQLite3->__construct('%s')
#1 {main}
Done