#49531 [NEW]: CURLOPT_INFILESIZE sometimes causes warning "CURLPROTO_FILE cannot be set"
| From: | gilad at parann dot net | Date: | Fri, 11 Sep 2009 12:40:13 +0000 |
| Subject: | #49531 [NEW]: CURLOPT_INFILESIZE sometimes causes warning "CURLPROTO_FILE cannot be set" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-142248@lists.php.net to get a copy of this message | ||
From: gilad at parann dot net
Operating system: any (was seen on Win32 XP)
PHP version: 5.2.10
PHP Bug Type: cURL related
Bug description: CURLOPT_INFILESIZE sometimes causes warning "CURLPROTO_FILE cannot be
set"
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 bug report at http://bugs.php.net/?id=49531&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49531&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49531&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49531&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49531&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49531&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49531&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49531&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49531&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49531&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49531&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49531&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49531&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49531&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49531&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49531&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49531&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49531&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49531&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49531&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49531&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49531&r=mysqlcfg