summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-10-13 01:11:30 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-10-13 01:11:30 +0000
commit8bd16e2b5890b6006d8362da0acb615053352ec7 (patch)
tree824923df92ca1d5156539d1f5b3317004b8d955d
parent33879eceb3ac0cb6f97b8029da5e1e32d20ab361 (diff)
downloadphp-git-8bd16e2b5890b6006d8362da0acb615053352ec7.tar.gz
Improve open_basedir checks
-rw-r--r--main/php_open_temporary_file.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index 63f4e2c06b..3132b9360e 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -206,7 +206,7 @@ PHPAPI const char* php_get_temporary_directory(void)
PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC)
{
int fd;
- const char *temp_dir = php_get_temporary_directory();
+ const char *temp_dir;
if (!pfx) {
pfx = "tmp.";
@@ -216,6 +216,9 @@ PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened
}
if (!dir || *dir == '\0') {
+def_tmp:
+ temp_dir = php_get_temporary_directory();
+
if (temp_dir && *temp_dir != '\0' && !php_check_open_basedir(temp_dir TSRMLS_CC)) {
return php_do_open_temporary_file(temp_dir, pfx, opened_path_p TSRMLS_CC);
} else {
@@ -227,7 +230,7 @@ PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened
fd = php_do_open_temporary_file(dir, pfx, opened_path_p TSRMLS_CC);
if (fd == -1) {
/* Use default temporary directory. */
- fd = php_do_open_temporary_file(temp_dir, pfx, opened_path_p TSRMLS_CC);
+ goto def_tmp;
}
return fd;
}