Skip to content

Commit 035ce93

Browse files
committed
Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction)
1 parent 168e892 commit 035ce93

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #61546 (functions related to current script failed when chdir()
77
in cli sapi). (Laruence, [email protected])
88

9+
- CURL
10+
. Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction).
11+
(Laruence)
12+
913
- Core:
1014
. Fixed missing bound check in iptcparse(). (chris at chiappa.net)
1115
. Fixed bug #61764 ('I' unpacks n as signed if n > 2^31-1 on LP64). (Gustavo)

ext/curl/interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
21672167

21682168
convert_to_string_ex(zvalue);
21692169

2170-
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))) {
2170+
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))) {
21712171
RETVAL_FALSE;
21722172
return 1;
21732173
}

ext/curl/tests/bug61948.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction)
3+
--SKIPIF--
4+
<?php if (!extension_loaded("curl")) print "skip"; ?>
5+
--INI--
6+
open_basedir="/tmp"
7+
--FILE--
8+
<?php
9+
$ch = curl_init();
10+
var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, ""));
11+
var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/foo"));
12+
var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, "/xxx/bar"));
13+
curl_close($ch);
14+
?>
15+
--EXPECTF--
16+
bool(false)
17+
bool(true)
18+
19+
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
20+
bool(false)

0 commit comments

Comments
 (0)