PHP 4.0 Bug #7245 Updated: ftp_rawlist fix
| From: | sniper@php.net | Date: | Sat, 28 Oct 2000 08:55:09 +0000 |
| Subject: | PHP 4.0 Bug #7245 Updated: ftp_rawlist fix | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-36212@lists.php.net to get a copy of this message | ||
ID: 7245
Updated by: sniper
Reported By: rxdev@serianet.com
Status: Closed
Bug Type: FTP related
Assigned To:
Comments:
Fixed in CVS. Thank you for this very good bug report!
--Jani
Previous Comments:
---------------------------------------------------------------------------
[2000-10-16 10:53:18] rxdev@serianet.com
ftp_rawlist() bug:
-----------------
The function ftp_rawlist() is not properly working when you
want to list the current directory without naming it (i.e. 'LIST' command without
parameters), e.g.
$arr=ftp_rawlist($fp,"")
is not working properly because PHP generates the command 'LIST ' (with supplemental space
after LIST) which is NOT recognized by many ftp servers.
The empty path (that should mean "current directory") is absolutely necessary as:
* ftp_rawlist($fp,".") or ftp_rawlist($fp,"./") lists RECURSIVELY the directory
on many ftpd servers : you can not use it to list the CWD
* rawlist($fp,<absolute path>) does NOT work with symlinks (the LIST <symlink> lists the
symlink itself!) on many other ftpd servers
The only temporary trick to list the current directory in raw mode is to do a
ftp_rawlist($fp,"-l") that generate a LIST -l
However, this is only a trick and therefore ftp_rawlist($fp,"") should be accepted
Here comes the reason of this bug, and the fix:
In ext/ftp/php_ftp.c you have the function PHP_FUNCTION(ftp_rawlist) defined, and this function
calls the following subfunctions:
PHP_FUNCTION(ftp_rawlist)
-> llist = ftp_list(ftp, arg2->value.str.val);
-> ftp_list(ftpbuf_t *ftp, const char *path)
-> ftp_genlist(ftp, "LIST", path);
-> if (!ftp_putcmd(ftp, cmd, path))
-> this one has a BUG
The bug is located in file ext/ftp/ftp.c, function ftp_putcmd() :
int
ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args)
{
int size;
char *data;
/* build the output buffer */
if (args) {
/* "cmd argsrn