Bug #73457 [NEW]: Wrong error message when fopen FTP wrapped fails to open data connection

From: Date: Fri, 04 Nov 2016 08:11:29 +0000
Subject: Bug #73457 [NEW]: Wrong error message when fopen FTP wrapped fails to open data connection
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205178@lists.php.net to get a copy of this message
From:             martin at winscp dot net
Operating system: Any
PHP version:      7.0.12
Package:          FTP related
Bug Type:         Bug
Bug description:Wrong error message when fopen FTP wrapped fails to open data connection

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.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=73457&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=73457&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=73457&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=73457&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=73457&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=73457&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=73457&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=73457&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=73457&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=73457&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=73457&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=73457&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=73457&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=73457&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73457&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=73457&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=73457&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=73457&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73457&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=73457&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=73457&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#205178) next »