xref: /php-src/Zend/tests/gh10469.phpt (revision 9bcdf219)
1--TEST--
2GH-10469: Disallow open_basedir() with parent dir components (..)
3--EXTENSIONS--
4zend_test
5--FILE--
6<?php
7ini_set('open_basedir', __DIR__);
8
9$pathSeparator = PHP_OS_FAMILY !== 'Windows' ? ':' : ';';
10$originalDir = __DIR__;
11$tmpDir = $originalDir . '/gh10469_tmp';
12@mkdir($tmpDir, 0777, true);
13chdir($tmpDir);
14ini_set('open_basedir', ini_get('open_basedir') . $pathSeparator . '.' . DIRECTORY_SEPARATOR . '..');
15ini_set('open_basedir', ini_get('open_basedir') . $pathSeparator . '.' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
16ini_set('open_basedir', ini_get('open_basedir') . $pathSeparator . '.' . DIRECTORY_SEPARATOR . 'a' . DIRECTORY_SEPARATOR);
17ini_set('open_basedir', ini_get('open_basedir') . $pathSeparator . '.' . DIRECTORY_SEPARATOR . 'a');
18
19chdir($originalDir);
20var_dump(ini_get('open_basedir'));
21var_dump(get_open_basedir());
22?>
23--CLEAN--
24<?php
25@rmdir(__DIR__ . '/gh10469_tmp');
26?>
27--EXPECTF--
28string(%d) "%stests%c.%e..%c.%e..%e%c.%ea%e%c.%ea"
29string(%d) "%stests%c%stests%c%stests%e%c%stests%egh10469_tmp%ea"
30