iliaa Wed Sep 27 23:44:13 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src NEWS
/php-src/main php_open_temporary_file.c
Log:
Fixed bug #38963 (Fixed a possible open_basedir bypass in tempnam()).
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.268&r2=1.2027.2.547.2.269&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.268 php-src/NEWS:1.2027.2.547.2.269
--- php-src/NEWS:1.2027.2.547.2.268 Wed Sep 27 10:32:49 2006
+++ php-src/NEWS Wed Sep 27 23:44:13 2006
@@ -8,6 +8,7 @@
(Dmitry)
- Fixed bug #38961 (metaphone() results in segmentation fault on NetBSD).
(Tony)
+- Fixed bug #38963 (Fixed a possible open_basedir bypass in tempnam()). (Ilia)
- Fixed bug #38949 (Cannot get xmlns value attribute). (Rob)
- Fixed bug #38942 (Double old-style-ctor inheritance). (Dmitry)
- Fixed bug #38941 (imap extension does not compile against new version of
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.c?r1=1.34.2.1.2.1&r2=1.34.2.1.2.2&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.1
php-src/main/php_open_temporary_file.c:1.34.2.1.2.2
--- php-src/main/php_open_temporary_file.c:1.34.2.1.2.1 Tue May 23 23:22:04 2006
+++ php-src/main/php_open_temporary_file.c Wed Sep 27 23:44:13 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_open_temporary_file.c,v 1.34.2.1.2.1 2006/05/23 23:22:04 iliaa Exp
$ */
+/* $Id: php_open_temporary_file.c,v 1.34.2.1.2.2 2006/09/27 23:44:13 iliaa Exp
$ */
#include "php.h"
@@ -206,6 +206,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.";
@@ -214,11 +215,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;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php