Bug #72092 [NEW]: CURLOPT_FILE is rewinded depending on stream type
| From: | bugs dot php dot net at ss dot st dot tc | Date: | Sun, 24 Apr 2016 06:41:24 +0000 |
| Subject: | Bug #72092 [NEW]: CURLOPT_FILE is rewinded depending on stream type | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-200741@lists.php.net to get a copy of this message | ||
From: bugs dot php dot net at ss dot st dot tc
Operating system: Linux
PHP version: 7.0.5
Package: cURL related
Bug Type: Bug
Bug description:CURLOPT_FILE is rewinded depending on stream type
Description:
------------
When using CURLOPT_FILE, file position indicator stays in the end when
the handle is a temporary stream. However the indicator is rewinded to 0
when the handle is a regular file (which seems to be a wrong
behaviour).
Tested in PHP 7.0.5 and 5.6.20.
Test script:
---------------
<?php
function test($filename) {
echo $filename, PHP_EOL;
$fh = fopen($filename, 'w');
$curl = curl_init('http://php.net/');
curl_setopt($curl, CURLOPT_FILE, $fh);
curl_exec($curl);
echo ' fstat size: ', fstat($fh)['size'], PHP_EOL;
echo ' ftell: ', ftell($fh), PHP_EOL;
}
test('regular-file.tmp');
test('php://temp');
Expected result:
----------------
regular-file.tmp
fstat size: 19371
ftell: 19371
php://temp
fstat size: 19371
ftell: 19371
Actual result:
--------------
regular-file.tmp
fstat size: 19371
ftell: 0
php://temp
fstat size: 19371
ftell: 19371
--
Edit bug report at https://bugs.php.net/bug.php?id=72092&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72092&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72092&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72092&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72092&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72092&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72092&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72092&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72092&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72092&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72092&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72092&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72092&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72092&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72092&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72092&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72092&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72092&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72092&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72092&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72092&r=mysqlcfg