php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49936 crash with ftp stream in php_stream_context_get_option()
Submitted: 2009-10-20 22:12 UTC Modified: 2009-11-28 16:38 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: marielyne at acanac dot net Assigned: pierrick (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.3SVN-2009-10-20 (snap) OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marielyne at acanac dot net
New email:
PHP Version: OS:

 

 [2009-10-20 22:12 UTC] marielyne at acanac dot net
Description:
------------
Trying to split a local file (at least 1 megabyte) to a FTP server ? la Hjsplit

PHP
=====
This snapshot was automatically generated on
Tue, 20 Oct 2009 19:16:25 +0000

Version: 5.3.2-dev
Branch: HEAD
Build: Release
=====

FTP
=====
FileZilla server 0.9.33
=====

Reproduce code:
---------------
http://www.pastebin.ca/1633753

Expected result:
----------------
*filename
fopen 2
fread
fwrite
[repeat last 2]
*filename
fopen 3
fread
fwrite
[repeat last 4]
done

Actual result:
--------------
*filename
fopen 2
fread
fwrite
*filename
CRASH

backtrace and FTP log @ http://www.pastebin.ca/1633797

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-21 12:36 UTC] jani@php.net
Does this happen with PHP 5.2.11 ? Does this happen using local filesystem instead of remote ftp site?
 [2009-10-21 14:58 UTC] marielyne at acanac dot net
Does not happen with 5.2.11
Does not happen with local directory

ftp://...@localhost/php5.dll.001
fopen 2
fread
fwrite
ftp://...@localhost/php5.dll.002
fopen 3
fread
fwrite
ftp://...@localhost/php5.dll.003
fopen 3
fread
fwrite
ftp://...@localhost/php5.dll.004
fopen 3
fread
fwrite
ftp://...@localhost/php5.dll.005
fopen 3
fread
fwrite
done
 [2009-10-24 20:06 UTC] marielyne at acanac dot net
New information

Reproduce code:
---------------
<?php
$file = 'ftp://your:self@localhost/test.txt';

echo "start\n";
$fo1 = fopen($file, 'rb');
echo "opened.1\n";
fclose($fo1);
echo "closed.1\n";
$fo2 = fopen($file, 'rb');
echo "opened.2\n";
fclose($fo2);
echo "closed.2\n";
?>


Expected result:
----------------
start
opened.1
closed.1
opened.2
closed.2


Actual result:
--------------
start
opened.1
closed.1


Same result if opening different files
Same result if opening different files from different servers

However, if I move first fclose() below second fopen(), it works as expected
 [2009-11-12 00:14 UTC] pierrick@php.net
The same problem can be reproduce with the following code 

<?php
$dir = 'ftp://your:self@localhost/';

opendir($dir);
opendir($dir);

This bug was introduce in 5.3 with the new way to manage references of stream context.

Patch can be found here (it modify the php_stream_context_set signature) :
http://www.adoy.net/php/stream-nofetch.diff

Or here (same version but with TSRMLS_FETCH to avoid any signature modification):
http://www.adoy.net/php/stream-fetch.diff
 [2009-11-15 20:30 UTC] svn@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=290796
Log: - Fixed bug #49936 (crash with ftp stream in php_stream_context_get_option())
  (patch by Pierrick)
 [2009-11-15 20:31 UTC] felipe@php.net
This bug has been fixed in SVN.

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.

Thanks for the patch!
 [2009-11-28 16:20 UTC] marielyne at acanac dot net
Did it make it in time for 5.3.1 ?
The opendir() test passes, but original issue remains

<?php
$file = 'ftp://ftp.gnu.org/gnu/m4/m4-1.4.13.tar.xz.sig';
var_dump(
 $fr1 = fopen($file, 'rb'),
 fclose($fr1),
 $fr2 = fopen($file, 'rb'),
 fclose($fr2)
);
?>
 [2009-11-28 16:38 UTC] pierrick@php.net
Unfortunately the patch was not applied on time for the 5.3.1 release and if I remember well, the opendir() test only crashed when PHP is compiled with --enable-debug. That's probably why you can't reproduce it.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC