Home » Networking » Net_FTP » Bug #2268
getRecursive does not work because of '.' and '..' directories
Details
| Submitted | 2004-09-01 18:54 UTC |
|---|---|
| From | joern_h at gmx dot net |
| Assigned | toby |
| Status | Closed |
| Package | Net_FTP |
| PHP Version | 4.3.0 |
| OS | Windows 2000 |
| Roadmaps | (Not assigned) |
Comments
[2004-09-01 18:54 UTC] joern_h at gmx dot net
Description:
------------
getRecursive tries to recurse into '.' directory and therefore hangs. A quick patch is attached.
Reproduce code:
---------------
C:\Programme\php\pear\Net>diff FTP.php ftp.php.jh
1305,1309c1305,1311
< $remote_path_new = $remote_path.$dir_entry["name"]."/";
< $local_path_new = $local_path.$dir_entry["name"]."/";
< $result = $this->getRecursive($remote_path_new, $local_path_new, $overwrite, $mode);
< if ($this->isError($result)) {
< return $result;
---
> if ($dir_entry['name'] != '.' && $dir_entry['name'] != '..') {
> $remote_path_new = $remote_path.$dir_entry["name"]."/";
> $local_path_new = $local_path.$dir_entry["name"]."/";
> $result = $this->getRecursive($remote_path_new, $local_path_new, $overwrite, $mode);
> if ($this->isError($result)) {
> return $result;
> }
[2004-09-07 18:16 UTC] joern_h at gmx dot net
FTP.php says it is Net_FTP Version 1.3
$Id: FTP.php,v 1.26 2004/06/14 22:26:48 toby Exp $
I upgraded to PHP 4.3.8 today and see the same behavior so its probably not a bug in the ftp extension.
Adding a print_r($dir_list) in getRecursive() before foreach ($dir_list as $dir_entry) shows the following output:
Array
(
[0] => Array
(
[name] => .
[size] => 4096
[rights] => rwx--x---
[user] => 22210
[group] => nobody
[files_inside] => 3
[date] => Sep 6 22:17
[is_dir] => d
[stamp] => 1094501820
)
[1] => Array
(
[name] => ..
[size] => 4096
[rights] => rwx--x---
[user] => 22210
[group] => nobody
[files_inside] => 6
[date] => Apr 18 19:51
[is_dir] => d
[stamp] => 1082310660
)
[2] => Array
(
[name] => news
[size] => 4096
[rights] => rwx--x---
[user] => 22210
[group] => nobody
[files_inside] => 3
[date] => Aug 23 16:43
[is_dir] => d
[stamp] => 1093272180
)
)
The code then tries to recurses into the '.' repeats this forever. If you need more information don't hesitate to ask.