php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64841 ftp_put() returns FALSE for some 2xx FTP response codes
Submitted: 2013-05-15 00:43 UTC Modified: 2018-03-19 17:06 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:3 (60.0%)
From: ky dot patterson at adlinkr dot com Assigned:
Status: Open Package: FTP related
PHP Version: 5.5.0RC1 OS: Linux
Private report: No CVE-ID: None
 [2013-05-15 00:43 UTC] ky dot patterson at adlinkr dot com
Description:
------------
Function ftp_put() should return TRUE (success) when it receives any FTP response code in the 2xx range, or at the least should return TRUE when it receives a standard FTP response code defined in RFC 959 in the 2xx range.

In particular it does not accept code 213 "File status" which is causing a problem for me.

I checked the source for PHP v5.3.25 and 5.5.0RC1 and it is the same in both, any response other than 226 or 250 or 200 is considered a failure.

Bug report 51190 indicates someone who had a similar problem with code 221.
In response to that ticket, ftp_put() was changed to accept code 200, however this does not represent a general solution to the problem (and in fact did not solve bug 51190 either according to its reporter.


Test script:
---------------
$ftp = ftp_connect('ftp.nowhere.com');
ftp_login($ftp, 'username', 'password');

$result = ftp_put($ftp, 'remote_file.bin', 'local_file.bin', FTP_BINARY);
/*
    STOR remote_file.bin
    150 File status okay; about to open data connection.
    216 closing data connection; File upload success; remote_file.bin
*/


Expected result:
----------------
1) $result is TRUE

2) No error is triggered

Actual result:
--------------
1) $result is FALSE

2) An error is triggered:
ftp_put(): File status okay; about to open data connection


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-19 17:06 UTC] cmb@php.net
> Function ftp_put() should return TRUE (success) when it receives
> any FTP response code in the 2xx range, or at the least should
> return TRUE when it receives a standard FTP response code defined
> in RFC 959 in the 2xx range.

RFC 959 is pretty strict regarding Command-Reply Sequences[1]:

| In this section, the command-reply sequence is presented.  Each
| command is listed with its possible replies; […]

The only command where a 213 is listed as possible reply is the
STAT command.

I'm not sure whether we should be more liberal in what we accept.

[1] <https://tools.ietf.org/html/rfc959#page-49>
 [2023-05-19 07:55 UTC] summertravelspot at gmail dot com
Summer Travel Spot Blog are  news about summer travel, hotel, resturants,travel spot etc. More info to visit:(https://summertravelspot.com)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 01:01:28 2024 UTC