summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-12-09 16:01:29 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-12-09 16:01:29 +0000
commit0236a7eaf4e6ae45cef81a2cfbff28ce4139d2b2 (patch)
tree1ca676df2d438e8751bce961d280b0e9a331f0a9 /ext
parent3d5fec9cb562e77990462515a303cf143ad737b8 (diff)
downloadphp-git-0236a7eaf4e6ae45cef81a2cfbff28ce4139d2b2.tar.gz
Fixed bug #29840 (is_executable() does not honor safe_mode_exec_dir
setting).
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/filestat.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index 5e98cc412e..0c113a3879 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -684,14 +684,27 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
"size", "atime", "mtime", "ctime", "blksize", "blocks"};
char *local;
php_stream_wrapper *wrapper;
+ char safe_mode_buf[MAXPATHLEN];
if (!filename_length) {
RETURN_FALSE;
}
if ((wrapper = php_stream_locate_url_wrapper(filename, &local, 0 TSRMLS_CC)) == &php_plain_files_wrapper) {
- if (php_check_open_basedir(local TSRMLS_CC) || (PG(safe_mode) && !php_checkuid_ex(filename, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS, CHECKUID_NO_ERRORS))) {
+ if (php_check_open_basedir(local TSRMLS_CC)) {
RETURN_FALSE;
+ } else if (PG(safe_mode)) {
+ if (type == FS_IS_X) {
+ if (strstr(local, "..")) {
+ RETURN_FALSE;
+ } else {
+ char *b = strrchr(local, PHP_DIR_SEPARATOR);
+ snprintf(safe_mode_buf, MAXPATHLEN, "%s%s%s", PG(safe_mode_exec_dir), (b ? "" : "/"), (b ? b : local));
+ local = (char *)&safe_mode_buf;
+ }
+ } else if (!php_checkuid_ex(local, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS, CHECKUID_NO_ERRORS)) {
+ RETURN_FALSE;
+ }
}
}