php.net |  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
 [2016-11-04 08:11 UTC] martin at winscp dot net
Description:
------------
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 http://stackoverflow.com/q/40415540/850848

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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-28 17:59 UTC] cmb@php.net
-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: https://github.com/php/php-src/pull/3466
 [2018-09-04 03:00 UTC] nikic@php.net
Automatic comment on behalf of vhu@iki.fi
Revision: http://git.php.net/?p=php-src.git;a=commit;h=742783c3ee4df424b5bd9130028951259ca52860
Log: Fixed bug #73457
 [2018-09-04 03:00 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC