]> granicus.if.org Git - php/commitdiff
- Fixed bug #52624 (tempnam() by-pass open_basedir with inexistent directory)
authorFelipe Pena <felipe@php.net>
Tue, 15 Nov 2011 16:59:59 +0000 (16:59 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 15 Nov 2011 16:59:59 +0000 (16:59 +0000)
NEWS
ext/standard/file.c
ext/standard/tests/file/bug52624.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 0e60c1e3d0a476d670b2013c4562cfbb10dc5c27..54e45362f218560e4817228f4f569c6e49185573 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 - Core:
   . Fixed bug #60227 (header() cannot detect the multi-line header with 
      CR(0x0D)). (rui)
+  . Fixed bug #52624 (tempnam() by-pass open_basedir with inexistent directory).
+    (Felipe)
 
 - OpenSSL:
   . Fixed bug #60279 (Fixed NULL pointer dereference in
index e86b21c7a6b33529ab86d8e81d77d3d15a38ab20..26000ea5a274d1fb0883c4863b836b43faeef1a6 100644 (file)
@@ -819,7 +819,7 @@ PHP_FUNCTION(tempnam)
        
        RETVAL_FALSE;
 
-       if ((fd = php_open_temporary_fd(dir, p, &opened_path TSRMLS_CC)) >= 0) {
+       if ((fd = php_open_temporary_fd_ex(dir, p, &opened_path, 1 TSRMLS_CC)) >= 0) {
                close(fd);
                RETVAL_STRING(opened_path, 0);
        }
diff --git a/ext/standard/tests/file/bug52624.phpt b/ext/standard/tests/file/bug52624.phpt
new file mode 100644 (file)
index 0000000..c8de056
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #52624 (tempnam() by-pass open_basedir with inexistent directory)
+--INI--
+open_basedir=.
+--FILE--
+<?php
+
+echo tempnam("directory_that_not_exists", "prefix_");
+
+?>
+--EXPECTF--
+Warning: tempnam(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (%s) in %s on line %d