Bug #72131 [Opn]: Calling number_format(null) causes curl to not decode chunks
| From: | andre at webkr dot de | Date: | Fri, 29 Apr 2016 23:05:01 +0000 |
| Subject: | Bug #72131 [Opn]: Calling number_format(null) causes curl to not decode chunks | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200839@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72131&edit=1
ID: 72131
User updated by: andre at webkr dot de
Reported by: andre at webkr dot de
Summary: Calling number_format(null) causes curl to not
decode chunks
Status: Open
Type: Bug
Package: Reproducible crash
Operating System: Linux
PHP Version: 5.5.35
Block user comment: N
Private report: N
New Comment:
Here's a Dockerfile that reproduces the bug and a little server (in Go) that returns chunked
responses:
https://github.com/AndreKR/php-bug-72131
Previous Comments:
------------------------------------------------------------------------
[2016-04-29 22:46:14] andre at webkr dot de
Description:
------------
This bug exists in PHP 5.5.35, PHP 5.6.21 and PHP 7.0.6.
When you make repeated curl requests to a server that returns the answer chunked-encoded, those
requests start to fail with the error "Problem (2) in the Chunked-Encoded data" as soon as
you call
number_format(null).
Admittedly number_format(null) makes no sense, but it throws no error either.
When you call number_format(null) a second time, cURL can decode chunks again, a third
time again brings the error, and so on.
Test script:
---------------
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/');
// This URL must return a chunked response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
for($i = 0 ; $i < 10 ; $i++)
{
$result = curl_exec($ch);
var_dump($result);
var_dump(curl_error($ch));
if($i >= 2) {
echo "\n" . 'number_format(null) called' . "\n";
number_format(null);
}
echo "\n";
}
Expected result:
----------------
(Created by requesting a URL that does not respond in chunks)
string(2) "OK"
string(0) ""
string(2) "OK"
string(0) ""
string(2) "OK"
string(0) ""
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
Actual result:
--------------
string(2) "OK"
string(0) ""
string(2) "OK"
string(0) ""
string(2) "OK"
string(0) ""
number_format(null) called
bool(false)
string(39) "Problem (2) in the Chunked-Encoded data"
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
bool(false)
string(39) "Problem (2) in the Chunked-Encoded data"
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
bool(false)
string(39) "Problem (2) in the Chunked-Encoded data"
number_format(null) called
string(2) "OK"
string(0) ""
number_format(null) called
bool(false)
string(39) "Problem (2) in the Chunked-Encoded data"
number_format(null) called
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72131&edit=1