From 71f115537380d35f41fbfff20f41d9c8200f8ca1 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Fri, 1 Dec 2006 17:11:07 +0000 Subject: [PATCH] MFH: fix bug #39458 --- NEWS | 1 + ext/ftp/ftp.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d8914f3e12..2003d4bb5c 100644 --- 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 diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index 4e63db90fe..a0f3d44787 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -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; -- 2.40.0