From: Andi Gutmans Date: Wed, 30 Aug 2000 20:31:17 +0000 (+0000) Subject: - Fix bug when using safe_mode and doc_root together X-Git-Tag: php-4.0.3RC1~410 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a2fa70fc915de14e413d312db4c6da00fdc1b9f;p=php - Fix bug when using safe_mode and doc_root together --- diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index eec07555ef..21674d57eb 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -413,16 +413,12 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char ** #else if (IS_SLASH(*filename)) { #endif - if (PG(safe_mode)) { - if(PG(doc_root)) { - snprintf(trypath, MAXPATHLEN, "%s%s", PG(doc_root), filename); - } else { - strlcpy(trypath,filename,sizeof(trypath)); - } + if (PG(safe_mode)&& PG(doc_root)) { + snprintf(trypath, MAXPATHLEN, "%s%s", PG(doc_root), filename); if (!php_checkuid(trypath, mode, 0)) { return NULL; } - return php_fopen_and_set_opened_path(filename, mode, opened_path); + return php_fopen_and_set_opened_path(trypath, mode, opened_path); } else { return php_fopen_and_set_opened_path(filename, mode, opened_path); }