php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14861 nlist and rawlist don`t work with ftp-daemon of Suse
Submitted: 2002-01-04 17:40 UTC Modified: 2002-07-10 23:17 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: bernd dot herbold at gmx dot de Assigned:
Status: Closed Package: FTP related
PHP Version: 4.1.1 OS: Linux and W2K
Private report: No CVE-ID: None
 [2002-01-04 17:40 UTC] bernd dot herbold at gmx dot de
Hello,

I tried to user ftp_nlist to get an directory-listing of an Suse7.1 
ftp-Server, but the function returns nothing.

I tried the same code to connect to an ftp-server on an Windows-System.

To analyse the problem I made some printentries in the file ftp.c. I edited 
the file in the array of line 1195. I think that here is one problem: 
the code expect "\r" and "\n", but only retrieves "\n".

Here is the code:


	while ((ch = getc(tmpfp)) != EOF) {
		printf("%d ",ch);
/*
		if (ch == '\n' && lastch == '\r') {
*/
		if (ch == '\n' ) {
			*(text - 1) = 0;
			printf("\nText:%s\n\n", text);
			*++entry = text;
		}
		else {
			*text++ = ch;
		}
		lastch = ch;
	}
	*entry = NULL;

	if (ferror(tmpfp))
		goto bail;

	fclose(tmpfp);

	if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) {
		free(ret);
		return NULL;
	}
	printf("ret[0]:%s\n", ret[0]);
	printf("ret[1]:%s\n\n", ret[1]);
	return ret;


And here is the output from my PHP-Script:

X-Powered-By: PHP/4.0.6
Content-type: text/html

45 114 119 45 114 45 45 114 45 45 32 32 49 32 114 111 111 116 32 32 32 114 111 111 116 32 32 32 49 54 51 57 32 68 101 99 32 50 49 32 50 51 58 51 48 32 105 99 97 112 46 112 104 112 10 
Text:icap.php
-rw-r-----  1 bernd  users  1717 Dec 21 23:29 kal.php


45 114 119 45 114 45 45 45 45 45 32 32 49 32 98 101 114 110 100 32 32 117 115 101 114 115 32 32 49 55 49 55 32 68 101 99 32 50 49 32 50 51 58 50 57 32 107 97 108 46 112 104 112 10 
Text:9 kal.php


ret[0]::?
ret[1]:-rw-r-----  1 bernd  users  1717 Dec 21 23:29 kal.ph

array(2) {
  [0]=>
  string(4) ":?"
  [1]=>
  string(52) "-rw-r-----  1 bernd  users  1717 Dec 21 23:29 kal.ph"
}


Thanks
Bernd

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-04 18:56 UTC] mfischer@php.net
Please test 4.1.1 and see if the problem still exists.
 [2002-01-05 07:05 UTC] bernd dot herbold at gmx dot de
Hello,

I tried to use PHP4.1.1, but there was the same Problem. Then I tried 
again to resolve the problem by my self, and it works! But I don't 
know if it is OK in connection with other FTP-server and want to use
my Script with several FTP-server on several plattforms.  I made the
following modifaktion in file ftp.c.

Line 1226:
	if (*ptr == '\n' )
Line 1254:
	if (ch == '\n' ) {


Can you use this for the standard? So that I can use the next Version?

Thanhs, Bernd

 [2002-01-19 17:34 UTC] bernd dot herbold at gmx dot de
Hello?
 [2002-03-04 07:03 UTC] bernd dot herbold at gmx dot de
I have found a workaround: If you try to get a file in binary mode befor you try to get the list, you would get a list. 
This also work if the file you order with ftp_get is not there.
 [2002-07-10 23:17 UTC] sniper@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 06:01:31 2024 UTC