php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35765 fopen wrapper using invalid SIZE command
Submitted: 2005-12-21 18:28 UTC Modified: 2005-12-22 15:09 UTC
From: jasonandtonya at gmail dot com Assigned:
Status: Not a bug Package: FTP related
PHP Version: 5CVS-2005-12-21 (snap) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
36 - 22 = ?
Subscribe to this entry?

 
 [2005-12-21 18:28 UTC] jasonandtonya at gmail dot com
Description:
------------
when opening a file via ftp as an array 

$logfile=fopen('ftp://example.com/filename.ext',"r");

it returns an error:

500 'SIZE filename.ext': command not understood and example.com is running a Solaris default ftp daemon.

Looking at the latest version 5.1-latest, (I'm assuming that it is using ftp_fopen_wrapper.c):

ftp_fopen_wrapper.c,v 1.85.2.2 2005/11/22 03:01:39
line 450:
        /* find out the size of the file (verifying it exists) */
        php_stream_printf(stream TSRMLS_CC, "SIZE %s\r\n", resource->path);

Is there a reason that you are using a non-standard command SIZE for verifying existance of the file?

Reproduce code:
---------------
$file=fopen('ftp://example.com/filename.ext',"r");

Expected result:
----------------
No error message when doing fopen

Actual result:
--------------
Warning: fopen('ftp://example.com/filename.ext') [function.fopen]: failed to open stream: FTP server reports 500 'SIZE filename.ext': command not understood. in /patrh/to/htdocs/filename.php on line 3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-21 21:28 UTC] sniper@php.net
"Is there a reason that you are using a non-standard command SIZE for verifying existance of the file?"

There propably is and this has worked fine since PHP 4. 
Get a working FTP server.
 [2005-12-22 15:09 UTC] jasonandtonya at gmail dot com
Wouldn't it be better to do a 

ls filename.ext

If the file does not exist, it will return 

200 PORT command successful.
550 filename.ext: No such file or directory.

Just providing some positive creative feedback for the wrapper for future improvements. You should have an alternate method if it fails. 

Command SIZE is not a standard for FTP (http://us2.php.net/ftp states you are refencing http://www.faqs.org/rfcs/rfc959 which shows SIZE is invalid) .

BTW: Since ftp server is running the most current version (Solaris 5.10 ftp daemon), I shouldn't have to be limited to  specific ftp server daemons for the wrapper to work.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC