]> granicus.if.org Git - php/commitdiff
MFH: fix bug #39458
authorNuno Lopes <nlopess@php.net>
Fri, 1 Dec 2006 17:11:07 +0000 (17:11 +0000)
committerNuno Lopes <nlopess@php.net>
Fri, 1 Dec 2006 17:11:07 +0000 (17:11 +0000)
NEWS
ext/ftp/ftp.c

diff --git a/NEWS b/NEWS
index d8914f3e126bb7bb533da3234c020dfe31987a12..2003d4bb5c048417cecf7d962f1b844862d2f39a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ PHP 4                                                                      NEWS
 - Fixed bug #39653 (ext/dba doesn't check for db-4.5 and db-4.4 when db4 
   support is enabled). (Tony)
 - Fixed bug #39583 (ftp_put() does not change transfer mode to ASCII). (Tony)
+- Fixed bug #39458 (ftp_nlist() returns false on empty dirs). (Nuno)
 - Fixed bug #39354 (Allow building of curl extension against libcurl
   7.16.0). (Ilia)
 - Fixed bug #39034 (curl_exec() with return transfer returns TRUE on empty
index 4e63db90fe4ef66ff683caf97c0c4f43367f61f9..a0f3d44787a103d79a15af02a61471cec034c8f9 100644 (file)
@@ -1498,9 +1498,14 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
 
        if (!ftp_putcmd(ftp, cmd, path))
                goto bail;
-       if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125))
+       if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125 && ftp->resp != 226))
                goto bail;
 
+       /* some servers don't open a ftp-data connection if the directory is empty */
+       if (ftp->resp == 226) {
+               return ecalloc(1, sizeof(char**));
+       }
+
        /* pull data buffer into tmpfile */
        if ((data = data_accept(data, ftp)) == NULL)
                goto bail;