Skip to content

Commit cf0657f

Browse files
committed
wip
1 parent ab26497 commit cf0657f

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

Zend/tests/gh10469.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
GH-10469: Disallow open_basedir() with parent dir components (..)
3+
--EXTENSIONS--
4+
zend_test
35
--FILE--
46
<?php
57
ini_set('open_basedir', __DIR__);
@@ -11,13 +13,16 @@ chdir($tmpDir);
1113
ini_set('open_basedir', ini_get('open_basedir') . ':.' . DIRECTORY_SEPARATOR . '..');
1214
ini_set('open_basedir', ini_get('open_basedir') . ':.' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
1315
ini_set('open_basedir', ini_get('open_basedir') . ':' . DIRECTORY_SEPARATOR . 'a' . DIRECTORY_SEPARATOR);
16+
ini_set('open_basedir', ini_get('open_basedir') . ':.' . DIRECTORY_SEPARATOR . 'a');
1417

1518
chdir($originalDir);
1619
var_dump(ini_get('open_basedir'));
20+
var_dump(get_open_basedir());
1721
?>
1822
--CLEAN--
1923
<?php
2024
@rmdir(__DIR__ . '/gh10469_tmp');
2125
?>
2226
--EXPECTF--
2327
string(%d) "%stests:.%e..:.%e..%e"
28+
string(%d) "%stests:%stests:%stests%e:%stests%egh10469_tmp%ea"

ext/zend_test/test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ static ZEND_FUNCTION(zend_get_map_ptr_last)
533533
RETURN_LONG(CG(map_ptr_last));
534534
}
535535

536+
static ZEND_FUNCTION(get_open_basedir)
537+
{
538+
ZEND_PARSE_PARAMETERS_NONE();
539+
RETURN_STRING(PG(open_basedir));
540+
}
541+
536542
static zend_object *zend_test_class_new(zend_class_entry *class_type)
537543
{
538544
zend_object *obj = zend_objects_new(class_type);

ext/zend_test/test.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ function zend_test_zend_call_stack_use_all(): int {}
192192
function zend_test_is_string_marked_as_valid_utf8(string $string): bool {}
193193

194194
function zend_get_map_ptr_last(): int {}
195+
196+
function get_open_basedir(): ?string {}
195197
}
196198

197199
namespace ZendTestNS {

ext/zend_test/test_arginfo.h

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main/fopen_wrappers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
9898
}
9999
char resolved_name[MAXPATHLEN + 1];
100100
if (expand_filepath(ptr, resolved_name) == NULL) {
101+
// efree(pathbuf);
101102
smart_str_free(&buf);
102103
return FAILURE;
103104
}

0 commit comments

Comments
 (0)