|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-09-11 12:40 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 01:00:01 2025 UTC |
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