dmitry Mon Oct 22 07:37:52 2007 UTC
Modified files:
/php-src/ext/standard basic_functions.c
Log:
Fixed move_uploaded_file() to always set file permissions of resulting file
according to UMASK (Andrew Sitnikov)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.879&r2=1.880&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.879
php-src/ext/standard/basic_functions.c:1.880
--- php-src/ext/standard/basic_functions.c:1.879 Sun Oct 7 05:15:06 2007
+++ php-src/ext/standard/basic_functions.c Mon Oct 22 07:37:52 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.879 2007/10/07 05:15:06 davidw Exp $ */
+/* $Id: basic_functions.c,v 1.880 2007/10/22 07:37:52 dmitry Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -52,6 +52,11 @@
#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
@@ -6050,6 +6055,10 @@
zval **pp_new_path;
zend_bool successful = 0;
+#ifndef PHP_WIN32
+ int oldmask; int ret;
+#endif
+
if (!SG(rfc1867_uploaded_files)) {
RETURN_FALSE;
}
@@ -6079,6 +6088,16 @@
VCWD_UNLINK(new_path);
if (VCWD_RENAME(old_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(old_path, new_path,
STREAM_DISABLE_OPEN_BASEDIR TSRMLS_CC) == SUCCESS) {
VCWD_UNLINK(old_path);
successful = 1;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php