|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73457 Wrong error message when fopen FTP wrapped fails to open data connection
Submitted: 2016-11-04 08:11 UTC Modified: 2016-11-28 17:59 UTC
From: martin at winscp dot net Assigned:
Status: Closed Package: Streams related
PHP Version: 7.0.12 OS: Any
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: martin at winscp dot net
New email:
PHP Version: OS:


 [2016-11-04 08:11 UTC] martin at winscp dot net
In the php_stream_url_wrap_ftp function in ext/standard/ftp_fopen_wrapper.c, the tmp_line local variable is used for two distinct purposes:

1) parsing SIZE response

    php_stream_notify_file_size(context, file_size, tmp_line, result);

2) constructing RETR/STOR/APPE request

    memcpy(tmp_line, "RETR", sizeof("RETR"));

When the function fails (jumps to errexit) the tmp_line variable is used to construct an error message:

    php_stream_wrapper_log_error(wrapper, options, "FTP server reports %s", tmp_line);

So when the function fails only after the tmp_line is reused for purpose 2), like when a data connection cannot be opened, the error message is nonsense like:

> failed to open stream: FTP server reports STOR

I'm reporting this based on this

The error is present at least since PHP 5.5, up to the PHP 7.0.12.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-28 17:59 UTC]
-Package: FTP related +Package: Streams related
 [2018-08-24 21:12 UTC] vhu at iki dot fi
Pull request has been added to fix this:
 [2018-09-04 03:00 UTC]
Automatic comment on behalf of
Log: Fixed bug #73457
 [2018-09-04 03:00 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 22:01:33 2024 UTC