diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-01-19 11:44:22 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-01-19 11:44:22 +0100 |
commit | 1bdd8f7ae43874876368d97dd89d88a517a2e80b (patch) | |
tree | c0c2151abde9b1a9a66e3dd0113f8fb90fadf878 /ext/standard | |
parent | f33105dcb6fb6f59801ebf122fd7223a41fa83aa (diff) | |
parent | 5d31ee302db073d5e99cf307315d2d631eaa34a5 (diff) | |
download | php-git-1bdd8f7ae43874876368d97dd89d88a517a2e80b.tar.gz |
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
Fixed bug #42560
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/file.c | 6 | ||||
-rw-r--r-- | ext/standard/tests/file/bug42560.phpt | 17 |
2 files changed, 18 insertions, 5 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c index c9cf1d29b0..d125f2b8e7 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -828,10 +828,6 @@ PHP_FUNCTION(tempnam) Z_PARAM_PATH(prefix, prefix_len) ZEND_PARSE_PARAMETERS_END(); - if (php_check_open_basedir(dir)) { - RETURN_FALSE; - } - p = php_basename(prefix, prefix_len, NULL, 0); if (ZSTR_LEN(p) > 64) { ZSTR_VAL(p)[63] = '\0'; @@ -839,7 +835,7 @@ PHP_FUNCTION(tempnam) RETVAL_FALSE; - if ((fd = php_open_temporary_fd_ex(dir, ZSTR_VAL(p), &opened_path, 1)) >= 0) { + if ((fd = php_open_temporary_fd_ex(dir, ZSTR_VAL(p), &opened_path, PHP_TMP_FILE_OPEN_BASEDIR_CHECK_ALWAYS)) >= 0) { close(fd); RETVAL_STR(opened_path); } diff --git a/ext/standard/tests/file/bug42560.phpt b/ext/standard/tests/file/bug42560.phpt new file mode 100644 index 0000000000..286ced6ff0 --- /dev/null +++ b/ext/standard/tests/file/bug42560.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #42560 Empty directory argument to tempnam yields open_basedir problems +--FILE-- +<?php +$tmpdir = sys_get_temp_dir(); +ini_set('open_basedir', $tmpdir); +$tempnam = tempnam('', 'test'); +var_dump($tempnam !== false); +var_dump(file_exists($tempnam)); + +if (file_exists($tempnam)) { + unlink($tempnam); +} +?> +--EXPECT-- +bool(true) +bool(true) |