#45220 [NEW]: curl_read callback returns -1 when needs to return size_t (unsigned)
| From: | brockn at gmail dot com | Date: | Mon, 09 Jun 2008 17:17:46 +0000 |
| Subject: | #45220 [NEW]: curl_read callback returns -1 when needs to return size_t (unsigned) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-125613@lists.php.net to get a copy of this message | ||
From: brockn at gmail dot com
Operating system: CentOS release 4.6 (Final)
PHP version: 5.2.6
PHP Bug Type: cURL related
Bug description: curl_read callback returns -1 when needs to return size_t (unsigned)
Description:
------------
curl_read, can return -1 when it explicitly states its return size_t. This
causes curl versions >= 7.18.X to fail with the attached code.
Curl stores the callback return value as int, but casts it to a size_t to
do a check. This causes the value to become very large and thus the check
fails when it should not.
I tried to download a snapshot and check that out, but the site appears to
be down.
Reproduce code:
---------------
<?php
$host= 'http://bashcurescancer.com/dump-request-variable.php';
$CR = curl_init();
curl_setopt($CR, CURLOPT_TIMEOUT, 60);
curl_setopt($CR, CURLOPT_URL, $host);
curl_setopt($CR, CURLOPT_POST, 1);
curl_setopt($CR, CURLOPT_FAILONERROR, true);
curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
$body = curl_exec( $CR );
$error = curl_error( $CR );
if( !empty( $error )) {
print("FAIL: $error\n");
exit(1);
} else {
print("PASS: " . trim($body) . "\n");
curl_close($CR);
exit(0);
}
?>
Expected result:
----------------
PASS: array (
)
Actual result:
--------------
FAIL: Failed to open/read local data from file/application
--
Edit bug report at http://bugs.php.net/?id=45220&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45220&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45220&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45220&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45220&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=45220&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45220&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45220&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45220&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45220&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45220&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=45220&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=45220&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45220&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45220&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45220&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45220&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45220&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45220&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45220&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45220&r=mysqlcfg