iliaa           Wed Sep 27 23:45:36 2006 UTC

  Modified files:              (Branch: PHP_4_4)
    /php-src/main       php_open_temporary_file.c 
    /php-src    NEWS 
  Log:
  MFH: Fixed bug #38963 (Fixed a possible open_basedir bypass in tempnam()).
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.c?r1=1.18.2.10.2.3&r2=1.18.2.10.2.4&diff_format=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.18.2.10.2.3 
php-src/main/php_open_temporary_file.c:1.18.2.10.2.4
--- php-src/main/php_open_temporary_file.c:1.18.2.10.2.3        Tue May 23 
23:23:39 2006
+++ php-src/main/php_open_temporary_file.c      Wed Sep 27 23:45:36 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.18.2.10.2.3 2006/05/23 23:23:39 iliaa 
Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.18.2.10.2.4 2006/09/27 23:45:36 iliaa 
Exp $ */
 
 #include "php.h"
 
@@ -207,6 +207,7 @@
 PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char 
**opened_path_p TSRMLS_DC)
 {
        int fd;
+       char *temp_dir = php_get_temporary_directory();
 
        if (!pfx) {
                pfx = "tmp.";
@@ -215,11 +216,19 @@
                *opened_path_p = NULL;
        }
 
+       if (!dir || *dir == '\0') {
+               if (temp_dir && *temp_dir != '\0' && 
!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;
+               }
+       }
+
        /* Try the directory given as parameter. */
        fd = php_do_open_temporary_file(dir, pfx, opened_path_p TSRMLS_CC);
        if (fd == -1) {
                /* Use default temporary directory. */
-               fd = php_do_open_temporary_file(php_get_temporary_directory(), 
pfx, opened_path_p TSRMLS_CC);
+               fd = php_do_open_temporary_file(temp_dir, pfx, opened_path_p 
TSRMLS_CC);
        }
        return fd;
 }
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.1247.2.920.2.163&r2=1.1247.2.920.2.164&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.920.2.163 php-src/NEWS:1.1247.2.920.2.164
--- php-src/NEWS:1.1247.2.920.2.163     Tue Sep 19 09:06:37 2006
+++ php-src/NEWS        Wed Sep 27 23:45:36 2006
@@ -2,6 +2,7 @@
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2006, Version 4.4.5
 - Updated PCRE to version 6.7. (Ilia)
+- Fixed bug #38963 (Fixed a possible open_basedir bypass in tempnam()). (Ilia)
 - Fixed bug #38534 (segfault when calling setlocale() in userspace session
   handler). (Tony)
 - Fixed bug #38450 (constructor is not called for classes used in userspace

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

Reply via email to