Skip to content

Commit 8e0cf44

Browse files
committed
fix bug #39458: ftp_nlist() returns false on empty dirs
1 parent 0742edb commit 8e0cf44

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ext/ftp/ftp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,10 +1614,15 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
16141614
if (!ftp_putcmd(ftp, cmd, path)) {
16151615
goto bail;
16161616
}
1617-
if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125)) {
1617+
if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125 && ftp->resp != 226)) {
16181618
goto bail;
16191619
}
16201620

1621+
/* some servers don't open a ftp-data connection if the directory is empty */
1622+
if (ftp->resp == 226) {
1623+
return ecalloc(1, sizeof(char**));
1624+
}
1625+
16211626
/* pull data buffer into tmpfile */
16221627
if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) {
16231628
goto bail;

0 commit comments

Comments
 (0)