|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-07-27 15:47 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 18:00:01 2025 UTC |
If safe_mode is on and touch is executed on a file *inside* the open_basedir directory, the file will *not* get created. This is because php_realpath() in main/php_realpath.c checks for the existence of the file before returning. If the file does not exist, NULL is returned, in which case the calling function exits with an error, causing touch to end with an error. Why should php_realpath care if the file it ends up with exists? It's sole purpose is to give the canonical path, regardless of whether it exists or not. So, the following patch fixes this problem: --- main/php_realpath.c.orig Tue Jul 25 22:50:08 2000 +++ main/php_realpath.c Tue Jul 25 23:28:02 2000 @@ -251,15 +251,18 @@ } /* Check if the resolved path is a directory */ - if (V_STAT(path_construction, &filestat) != 0) return NULL; - if (S_ISDIR(filestat.st_mode)) { - /* It's a directory, append a / if needed */ - if (*(writepos-1) != '/') { - /* Check for overflow */ - if ((strlen(workpos) + 2) >= MAXPATHLEN) return NULL; + if (V_STAT(path_construction, &filestat) != 0) { + if (errno != ENOENT) return NULL; + } else { + if (S_ISDIR(filestat.st_mode)) { + /* It's a directory, append a / if needed */ + if (*(writepos-1) != '/') { + /* Check for overflow */ + if ((strlen(workpos) + 2) >= MAXPATHLEN) return NULL; - *writepos++ = '/'; - *writepos = 0; + *writepos++ = '/'; + *writepos = 0; + } } }