#45220 [Csd]: curl_read callback returns -1 when needs to return size_t (unsigned)

2008-08-13 Thread brockn at gmail dot com
 ID:   45220
 User updated by:  brockn at gmail dot com
 Reported By:  brockn at gmail dot com
 Status:   Closed
 Bug Type: cURL related
 Operating System: CentOS release 4.6 (Final)
 PHP Version:  5.2.6
 New Comment:

Looks like php 4.4.9 is still broken. I know its not supported anymore,
but people are going to be using it for quite some time so I'd think it
might be prudent to fix itgiven that its so simple.


Previous Comments:


[2008-07-12 21:20:53] [EMAIL PROTECTED]

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.





[2008-07-12 20:34:52] nicolas at brousse dot info

You can also simply patch php source by fixing line 789 in
ext/curl/interface.c :

# before
int length = -1;
# after
int length = 0;



[2008-06-16 17:32:15] brockn at gmail dot com

Yes, if you set POSTFIELDS to , then curl_read does not return -1.
The root of the problem is that the default return value is -1, when it
should be 0 as it returns a size_t which is an unsigned type.

A check was added in libcurl 7.18 where the value is cast to size_t and
compared. This is the ``effect'' of the problem, but the cause is that
the php supplied curl_read callback is returning -1.



[2008-06-16 17:25:25] randearievilo at gmail dot com

I have a similar code using cURL that worked fine in two platforms, but
failed on other two.

Platforms working:
- Debian 4.0 / PHP 5.2.0 / Apache 2.2.8 / libcurl 7.15.5
- Windows XP / PHP 4.4.7 / Apache 1.3.39 / libcurl 7.16.0

Platforms not working:
- Linux / PHP 4.4.7 / Apache 1.3.41 / libcurl 7.18.1
- Linux / PHP 5.2.5 / Apache 1.3.41 / libcurl 7.18.1

As you can see, the libcurl 7.18.x may really have a
bug/error/problem.
I think there was a change in the option CURLOPT_POST. Now, to use this
option, it seems to be necessary to set the option CURLOPT_POSTFIELDS
(curl_setopt($ch, CURLOPT_POSTFIELDS, );).



[2008-06-09 19:07:32] brockn at gmail dot com

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



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/45220

-- 
Edit this bug report at http://bugs.php.net/?id=45220edit=1



#45220 [Opn]: curl_read callback returns -1 when needs to return size_t (unsigned)

2008-06-16 Thread brockn at gmail dot com
 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:

Yes, if you set POSTFIELDS to , then curl_read does not return -1.
The root of the problem is that the default return value is -1, when it
should be 0 as it returns a size_t which is an unsigned type.

A check was added in libcurl 7.18 where the value is cast to size_t and
compared. This is the ``effect'' of the problem, but the cause is that
the php supplied curl_read callback is returning -1.


Previous Comments:


[2008-06-16 17:25:25] randearievilo at gmail dot com

I have a similar code using cURL that worked fine in two platforms, but
failed on other two.

Platforms working:
- Debian 4.0 / PHP 5.2.0 / Apache 2.2.8 / libcurl 7.15.5
- Windows XP / PHP 4.4.7 / Apache 1.3.39 / libcurl 7.16.0

Platforms not working:
- Linux / PHP 4.4.7 / Apache 1.3.41 / libcurl 7.18.1
- Linux / PHP 5.2.5 / Apache 1.3.41 / libcurl 7.18.1

As you can see, the libcurl 7.18.x may really have a
bug/error/problem.
I think there was a change in the option CURLOPT_POST. Now, to use this
option, it seems to be necessary to set the option CURLOPT_POSTFIELDS
(curl_setopt($ch, CURLOPT_POSTFIELDS, );).



[2008-06-09 19:07:32] brockn at gmail dot com

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



[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=45220edit=1



#45220 [NEW]: curl_read callback returns -1 when needs to return size_t (unsigned)

2008-06-09 Thread brockn at gmail dot com
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=45220edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45220r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45220r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45220r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45220r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=45220r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=45220r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=45220r=needscript
Try newer version:http://bugs.php.net/fix.php?id=45220r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=45220r=support
Expected behavior:http://bugs.php.net/fix.php?id=45220r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=45220r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=45220r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45220r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45220r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45220r=dst
IIS Stability:http://bugs.php.net/fix.php?id=45220r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=45220r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45220r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=45220r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=45220r=mysqlcfg



#45220 [Opn]: curl_read callback returns -1 when needs to return size_t (unsigned)

2008-06-09 Thread brockn at gmail dot com
 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=45220edit=1