iliaa           Tue Jul 17 23:46:40 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/main       php_open_temporary_file.c php_open_temporary_file.h 
                        rfc1867.c 
  Log:
  
  Allow file uploads to bypass open_basedir checks (fixes regression)
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.c?r1=1.34.2.1.2.7&r2=1.34.2.1.2.8&diff_format=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.34.2.1.2.7 
php-src/main/php_open_temporary_file.c:1.34.2.1.2.8
--- php-src/main/php_open_temporary_file.c:1.34.2.1.2.7 Wed Feb  7 21:07:31 2007
+++ php-src/main/php_open_temporary_file.c      Tue Jul 17 23:46:40 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.34.2.1.2.7 2007/02/07 21:07:31 tony2001 
Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.34.2.1.2.8 2007/07/17 23:46:40 iliaa Exp 
$ */
 
 #include "php.h"
 
@@ -211,7 +211,7 @@
  * This function should do its best to return a file pointer to a newly created
  * unique file, on every platform.
  */
-PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char 
**opened_path_p TSRMLS_DC)
+PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, char 
**opened_path_p, zend_bool open_basedir_check TSRMLS_DC)
 {
        int fd;
        const char *temp_dir;
@@ -227,7 +227,7 @@
 def_tmp:
                temp_dir = php_get_temporary_directory();
 
-               if (temp_dir && *temp_dir != '\0' && 
!php_check_open_basedir(temp_dir TSRMLS_CC)) {
+               if (temp_dir && *temp_dir != '\0' && (!open_basedir_check || 
!php_check_open_basedir(temp_dir TSRMLS_CC))) {
                        return php_do_open_temporary_file(temp_dir, pfx, 
opened_path_p TSRMLS_CC);
                } else {
                        return -1;
@@ -243,6 +243,11 @@
        return fd;
 }
 
+PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char 
**opened_path_p TSRMLS_DC)
+{
+       return php_open_temporary_fd_ex(dir, pfx, opened_path_p, 0 TSRMLS_CC);
+}
+
 PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char 
**opened_path_p TSRMLS_DC)
 {
        FILE *fp;
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.h?r1=1.13.2.1.2.2&r2=1.13.2.1.2.3&diff_format=u
Index: php-src/main/php_open_temporary_file.h
diff -u php-src/main/php_open_temporary_file.h:1.13.2.1.2.2 
php-src/main/php_open_temporary_file.h:1.13.2.1.2.3
--- php-src/main/php_open_temporary_file.h:1.13.2.1.2.2 Wed Feb  7 21:01:06 2007
+++ php-src/main/php_open_temporary_file.h      Tue Jul 17 23:46:40 2007
@@ -16,13 +16,14 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_open_temporary_file.h,v 1.13.2.1.2.2 2007/02/07 21:01:06 helly Exp 
$ */
+/* $Id: php_open_temporary_file.h,v 1.13.2.1.2.3 2007/07/17 23:46:40 iliaa Exp 
$ */
 
 #ifndef PHP_OPEN_TEMPORARY_FILE_H
 #define PHP_OPEN_TEMPORARY_FILE_H
 
 BEGIN_EXTERN_C()
 PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char 
**opened_path_p TSRMLS_DC);
+PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, char 
**opened_path_p, zend_bool open_basedir_check TSRMLS_DC);
 PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char 
**opened_path_p TSRMLS_DC);
 PHPAPI const char *php_get_temporary_directory(void);
 PHPAPI void php_shutdown_temporary_directory();
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.173.2.1.2.8&r2=1.173.2.1.2.9&diff_format=u
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.173.2.1.2.8 
php-src/main/rfc1867.c:1.173.2.1.2.9
--- php-src/main/rfc1867.c:1.173.2.1.2.8        Sat Feb 24 14:53:50 2007
+++ php-src/main/rfc1867.c      Tue Jul 17 23:46:40 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: rfc1867.c,v 1.173.2.1.2.8 2007/02/24 14:53:50 helly Exp $ */
+/* $Id: rfc1867.c,v 1.173.2.1.2.9 2007/07/17 23:46:40 iliaa Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -1016,7 +1016,7 @@
 
                        if (!skip_upload) {
                                /* Handle file */
-                               fd = php_open_temporary_fd(PG(upload_tmp_dir), 
"php", &temp_filename TSRMLS_CC);
+                               fd = 
php_open_temporary_fd_ex(PG(upload_tmp_dir), "php", &temp_filename, 1 
TSRMLS_CC);
                                if (fd==-1) {
                                        sapi_module.sapi_error(E_WARNING, "File 
upload error - unable to create a temporary file");
                                        cancel_upload = UPLOAD_ERROR_E;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to