ID: 49531
Comment by: bonecollector at hot dot ee
Reported By: gilad at parann dot net
Status: Open
Bug Type: cURL related
Operating System: any (was seen on Win32 XP)
PHP Version: 5.2.10
New Comment:
Seems, that other options cause also this warning:
<?
$chk_time=date('2009-08-07 10:10:10');
$resURL = curl_init();
curl_setopt($resURL, CURLOPT_URL, 'http://google.com');
curl_setopt($resURL, CURLOPT_TIMECONDITION,
CURL_TIMECOND_IFMODSINCE);
curl_setopt($resURL, CURLOPT_TIMEVALUE, $chk_time);
curl_setopt($resURL, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($resURL, CURLOPT_HEADER, TRUE);
$pageData=curl_exec($resURL);
echo "Got result:<br>";
echo $pageData;
?>
and you will get same warning on line 7 (curl_setopt($resURL,
CURLOPT_TIMEVALUE, $chk_time);)
Searching at google, it seems that many-many pages have been broken
Previous Comments:
------------------------------------------------------------------------
[2009-09-12 17:01:07] gilad at parann dot net
Further detail:
This was with PHP 5.2.10 and libcurl 7.19.4 in Apache 2.2.11 on Win32
(XP)
------------------------------------------------------------------------
[2009-09-11 12:40:12] gilad at parann dot net
Description:
------------
Set up PHP 5.2.10 with a basedir.
Calling
curl_setopt ($ch, CURLOPT_INFILESIZE, $len) ;
will sometimes cause PHP to generate a warning
CURLPROTO_FILE cannot be activated when in safe_mode or an open_basedir
is set
depending on the exact value of $len !!!
Looking at the source code of _php_curl_setopt (from
"...ext/curl/interface.c") I think I see why. The code starts with a big
switch statement and NO break...
So the CURLOPT_INFILESIZE option gets processed by the IF statement
that checks if "(Z_LVAL_PP(zvalue) & CURLPROTO_FILE)" !!
Sometimes the $len value will happen to have the same bits set as
CURLPROTO_FILE and boom - you get the error.
Anyway if you avoid setting INFILESIZE things do work - only sometimes
that is not so convenient...
Reproduce code:
---------------
from _php_curl_setopt in "...ext/curl/interface.c":
switch (option) {
case CURLOPT_INFILESIZE:
/* .... many many more options with NO break! */
case CURLOPT_REDIR_PROTOCOLS:
case CURLOPT_PROTOCOLS:
convert_to_long_ex(zvalue);
if (((PG(open_basedir) && *PG(open_basedir)) ||
PG(safe_mode)) &&
(Z_LVAL_PP(zvalue) & CURLPROTO_FILE)) {
php_error_docref(NULL TSRMLS_CC,
E_WARNING, "CURLPROTO_FILE cannot
be activated when in safe_mode or an open_basedir is set");
RETVAL_FALSE;
return 1;
}
error = curl_easy_setopt(ch->cp, option,
Z_LVAL_PP(zvalue));
break;
Expected result:
----------------
I expect the call to curl_setopt with CURLOPT_INFILESIZE to work
Actual result:
--------------
A warning is generated
CURLPROTO_FILE cannot be activated when in safe_mode or an open_basedir
is set
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49531&edit=1