php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39458 ftp_nlist returns false on empty directories
Submitted: 2006-11-10 12:04 UTC Modified: 2007-01-03 22:48 UTC
Votes:4
Avg. Score:3.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: brain at eucoders dot com Assigned: nlopess (profile)
Status: Closed Package: FTP related
PHP Version: 4.4.5-dev OS: Rehat Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: brain at eucoders dot com
New email:
PHP Version: OS:

 

 [2006-11-10 12:04 UTC] brain at eucoders dot com
Description:
------------
ftp_nlist returns false on empty directories


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-10 12:06 UTC] brain at eucoders dot com
ftp_nlist returns false on empty directories instead of empty array
 [2006-11-10 12:07 UTC] brain at eucoders dot com
It seems that ftp_rawlist has the corrected behaviour and it is returning an empty array.
 [2006-11-10 14:20 UTC] brain at eucoders dot com
The problem is that the developer cannot use this ftp_rawlist in case the directory do not exist. In that case, ftp_nlist will return false (unreliable result) and ftp_rawlist return Array() which is again unreliable.

The best fix would be that ftp_nlist return false when the directory does not exist, and Array() when directory is empty.
 [2006-11-10 16:18 UTC] brain at eucoders dot com
It appears that this problem appears on php 4.4.4 and also 4.3.2 version. Other versions should contain the same problem.
 [2006-12-01 06:53 UTC] mspreij at gmail dot com
Seeing similar errors in PHP 5.1.6 on Ubuntu:
- with (local) ftp server ProFTPD, ftp_nlist() returns false for both empty and non-existing directories. ftp_rawlist() behaves properly.
- with external ftp server vsFTPd 2.0.1 (on RedHat), it returns proper empty array, but then that /also/ returns empty arrays for non-existing paths, should be boolean false? ftp_rawlist() does the same strange thing here: empty arrays for both empty and non-existing directories.
 [2006-12-01 16:02 UTC] nlopess@php.net
can you please provide a network dump (e.g. with ethereal) of the connections to the ftp server? (or can you provide the address of your ftp server)
I can't reproduce your problem with a few servers I tried. 
 [2006-12-01 16:12 UTC] nlopess@php.net
OK, forget my last comment. I found a server that exibists this behaviour (ftp.freeradius.org/pub/suse/i386).
I'll work on a patch.
 [2006-12-01 16:38 UTC] nlopess@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2007-01-03 17:06 UTC] brain at eucoders dot com
I installed:

php4 (tar.bz2) (4.3M) php4 (tar.gz) (5.3M) 
Built On: Jan 03, 2007 15:30 GMT

but the problem still appear.
 [2007-01-03 17:07 UTC] brain at eucoders dot com
The sequence of the code is:

ftpconnect();
echo "'";
$a=ftp_nlist($ftp_id, '/httpdocs/_site/s/5/0/3/t');
if($a===false) echo 'false';
else print_r($a);
echo "'";
ftpclose();

(ftpconnect and ftpclose are my defined functions to connect to ftp server)
 [2007-01-03 17:10 UTC] brain at eucoders dot com
The previous sequence is returning false even though the directory exists and have 777 permissions.
 [2007-01-03 18:10 UTC] nlopess@php.net
I didn't merge the patches to PHP 4..
 [2007-01-03 18:24 UTC] brain at eucoders dot com
Ok, after testing and testing and testing I got a nasty conclusion...

After testing:
http://www.phpclasses.org/browse/package/3174.html
http://www.phpclasses.org/browse/package/2137.html
http://www.phpclasses.org/browse/package/1244.html
which are simple clases to handle FTP without builtin functions I got the same result which is "false" instead of "array()".

That gave me the conclusion that it can be another bug in my ProFTP server 1.2.9 and I tried the same scripts for a different ftp server and worked fine.

I think I will try to update ProFTP as well, and check again and post a bug on their site.

Thanx.
 [2007-01-03 20:06 UTC] nlopess@php.net
After all, I had already merged the patch to php 4.4 some time ago. So I really need access to your FTP server (an anonymous account is sufficient)
 [2007-01-03 22:48 UTC] nlopess@php.net
OK, I have analysed your server response and it is returning a non-valid response (code 450).
searching a little leads to:
http://bugs.proftpd.org/show_bug.cgi?id=2863
http://bugs.proftpd.org/show_bug.cgi?id=2861

comment from the proftpd developer: "Resolved in 1.3.1rc1", so you'll need to upgrade proftpd as well.

Closing bug report as the problem was already fixed (it didn't worked with a valid return code: 226)
 [2015-09-29 08:04 UTC] tejasrathod02 at gmail dot com
I can able to draw the line transperently with pen passing through the obstacles of stage.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC