#45220 [Opn]: curl_read callback returns -1 when needs to return size_t (unsigned)
| From: | brockn at gmail dot com | Date: | Mon, 09 Jun 2008 19:07:33 +0000 |
| Subject: | #45220 [Opn]: curl_read callback returns -1 when needs to return size_t (unsigned) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-125621@lists.php.net to get a copy of this message | ||
ID: 45220
User updated by: brockn at gmail dot com
Reported By: brockn at gmail dot com
Status: Open
Bug Type: cURL related
Operating System: CentOS release 4.6 (Final)
PHP Version: 5.2.6
New Comment:
Here are the details of the problem which occurs inside libcurl:
http://curl.haxx.se/mail/lib-2008-06/0109.html
http://curl.haxx.se/mail/lib-2008-06/0111.html
http://curl.haxx.se/mail/lib-2008-06/0123.html
Previous Comments:
------------------------------------------------------------------------
[2008-06-09 17:17:46] brockn at gmail dot com
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 this bug report at http://bugs.php.net/?id=45220&edit=1