diff options
author | Dmitry Stogov <dmitry@php.net> | 2007-10-22 07:37:37 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2007-10-22 07:37:37 +0000 |
commit | fa6e5df12642eaeb80c1f97a223e92472dfa6e94 (patch) | |
tree | 14d0744a9684359ec17d772f5afc072582b78561 | |
parent | 7f32916af0cf9a8b2e80433f37dfdba610685be3 (diff) | |
download | php-git-fa6e5df12642eaeb80c1f97a223e92472dfa6e94.tar.gz |
Fixed move_uploaded_file() to always set file permissions of resulting file according to UMASK (Andrew Sitnikov)
-rw-r--r-- | ext/standard/basic_functions.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index cf10e21cea..81e1208f56 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -53,6 +53,11 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #include <time.h> #include <stdio.h> +#ifndef PHP_WIN32 +#include <sys/types.h> +#include <sys/stat.h> +#endif + #ifdef NETWARE #include <netinet/in.h> #endif @@ -6061,6 +6066,10 @@ PHP_FUNCTION(move_uploaded_file) int path_len, new_path_len; zend_bool successful = 0; +#ifndef PHP_WIN32 + int oldmask; int ret; +#endif + if (!SG(rfc1867_uploaded_files)) { RETURN_FALSE; } @@ -6084,6 +6093,16 @@ PHP_FUNCTION(move_uploaded_file) VCWD_UNLINK(new_path); if (VCWD_RENAME(path, new_path) == 0) { successful = 1; +#ifndef PHP_WIN32 + oldmask = umask(077); + umask(oldmask); + + ret = VCWD_CHMOD(new_path, 0666 & ~oldmask); + + if (ret == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); + } +#endif } else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR TSRMLS_CC) == SUCCESS) { VCWD_UNLINK(path); successful = 1; |