php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72092 CURLOPT_FILE is rewinded depending on stream type
Submitted: 2016-04-24 06:41 UTC Modified: 2019-03-26 17:28 UTC
Votes:5
Avg. Score:2.6 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: bugs dot php dot net at ss dot st dot tc Assigned:
Status: Verified Package: cURL related
PHP Version: 7.0.5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bugs dot php dot net at ss dot st dot tc
New email:
PHP Version: OS:

 

 [2016-04-24 06:41 UTC] bugs dot php dot net at ss dot st dot tc
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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-03 15:49 UTC] vonubrog at gmail dot com
Same here with PHP 7.0.9 and 5.4.45. Such an annoying inconsistency :(
 [2019-03-26 16:29 UTC] mike@php.net
Probably fixable by upgrading internals to streams instead of stdio.

Related to Bug #76268 and Bug #70693
 [2019-03-26 17:28 UTC] mike@php.net
-Status: Open +Status: Verified
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 06:01:30 2024 UTC