com php-src: Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction): NEWS ext/cur l/interface.c ext/curl/tests/bug61948.phpt
| From: | Xinchen Hui | Date: | Sat, 05 May 2012 16:40:49 +0000 |
| Subject: | com php-src: Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction): NEWS ext/cur l/interface.c ext/curl/tests/bug61948.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-68960@lists.php.net to get a copy of this message | ||
Commit: 035ce937e13d8496795cef9899cc5c5afe9daab7
Author: Xinchen Hui <laruence@php.net> Sun, 6 May 2012 00:40:49 +0800
Parents: 168e8920be77f3b55a3ae688270b752579681f6e
Branches: PHP-5.3
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=035ce937e13d8496795cef9899cc5c5afe9daab7
Log:
Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction)
Bugs:
https://bugs.php.net/61948
Changed paths:
M NEWS
M ext/curl/interface.c
A ext/curl/tests/bug61948.phpt
Diff:
diff --git a/NEWS b/NEWS
index 7bb6cc0...e4bc495 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #61546 (functions related to current script failed when chdir()
in cli sapi). (Laruence, reeze.xia@gmail.com)
+- CURL
+ . Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction).
+ (Laruence)
+
- Core:
. Fixed missing bound check in iptcparse(). (chris at chiappa.net)
. Fixed bug #61764 ('I' unpacks n as signed if n > 2^31-1 on LP64). (Gustavo)
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 66aafc0..270a7dd 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -2167,7 +2167,7 @@ string_copy:
convert_to_string_ex(zvalue);
- if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC) || (PG(safe_mode) &&
!php_checkuid(Z_STRVAL_PP(zvalue), "rb+", CHECKUID_CHECK_MODE_PARAM))) {
+ if (!Z_STRLEN_PP(zvalue) || php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC) ||
(PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(zvalue), "rb+",
CHECKUID_CHECK_MODE_PARAM))) {
RETVAL_FALSE;
return 1;
}
diff --git a/ext/curl/tests/bug61948.phpt b/ext/curl/tests/bug61948.phpt
new file mode 100644
index 0000000..a03fc3b
--- /dev/null
+++ b/ext/curl/tests/bug61948.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction)
+--SKIPIF--
+<?php if (!extension_loaded("curl")) print "skip"; ?>
+--INI--
+open_basedir="/tmp"
+--FILE--
+<?php
+ $ch = curl_init();
+ var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, ""));
+ var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/foo"));
+ var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, "/xxx/bar"));
+ curl_close($ch);
+?>
+--EXPECTF--
+bool(false)
+bool(true)
+
+Warning: curl_setopt(): open_basedir restriction in effect. File(/xxx/bar) is not within the
allowed path(s): (/tmp) in %sbug61948.php on line %d
+bool(false)