#49531 [Opn]: CURLOPT_INFILESIZE sometimes causes warning "CURLPROTO_FILE cannot be set"
| From: | gilad at parann dot net | Date: | Sat, 12 Sep 2009 17:01:07 +0000 |
| Subject: | #49531 [Opn]: CURLOPT_INFILESIZE sometimes causes warning "CURLPROTO_FILE cannot be set" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-142283@lists.php.net to get a copy of this message | ||
ID: 49531
User updated by: gilad at parann dot net
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:
Further detail:
This was with PHP 5.2.10 and libcurl 7.19.4 in Apache 2.2.11 on Win32
(XP)
Previous Comments:
------------------------------------------------------------------------
[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