From c2c3535e0235f3e587072fbc0ff1b75fde924b69 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Sun, 16 Jun 1996 02:26:19 +0000 Subject: [PATCH] Don't just send data in plain when doing NLST. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@595 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftpd/ftpd.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/appl/ftp/ftpd/ftpd.c b/appl/ftp/ftpd/ftpd.c index e82466114..5c191a51e 100644 --- a/appl/ftp/ftpd/ftpd.c +++ b/appl/ftp/ftpd/ftpd.c @@ -1698,6 +1698,8 @@ send_file_list(char *whichf) int freeglob = 0; glob_t gl; + char buf[MaxPathLen]; + if (strpbrk(whichf, "~{[*?") != NULL) { int flags = GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE; @@ -1750,8 +1752,9 @@ send_file_list(char *whichf) goto out; transflag++; } - fprintf(dout, "%s%s\n", dirname, + sprintf(buf, "%s%s\n", dirname, type == TYPE_A ? "\r" : ""); + auth_write(fileno(dout), buf, strlen(buf)); byte_count += strlen(dirname) + 1; continue; } else if (!S_ISDIR(st.st_mode)) @@ -1775,26 +1778,25 @@ send_file_list(char *whichf) * not a directory or special file. */ if (simple || (stat(nbuf, &st) == 0 && - S_ISREG(st.st_mode))) { - if (dout == NULL) { - dout = dataconn("file list", (off_t)-1, - "w"); - if (dout == NULL) - goto out; - transflag++; - } - if (nbuf[0] == '.' && nbuf[1] == '/') - fprintf(dout, "%s%s\n", &nbuf[2], - type == TYPE_A ? "\r" : ""); - else - fprintf(dout, "%s%s\n", nbuf, - type == TYPE_A ? "\r" : ""); - byte_count += strlen(nbuf) + 1; + S_ISREG(st.st_mode))) { + if (dout == NULL) { + dout = dataconn("file list", (off_t)-1, "w"); + if (dout == NULL) + goto out; + transflag++; + } + if(strncmp(nbuf, "./", 2) == 0) + sprintf(buf, "%s%s\n", nbuf +2, + type == TYPE_A ? "\r" : ""); + else + sprintf(buf, "%s%s\n", nbuf, + type == TYPE_A ? "\r" : ""); + auth_write(fileno(dout), buf, strlen(buf)); + byte_count += strlen(nbuf) + 1; } } (void) closedir(dirp); } - if (dout == NULL) reply(550, "No files found."); else if (ferror(dout) != 0) @@ -1803,8 +1805,11 @@ send_file_list(char *whichf) reply(226, "Transfer complete."); transflag = 0; - if (dout != NULL) - (void) fclose(dout); + if (dout != NULL){ + auth_write(fileno(dout), buf, 0); /* XXX flush */ + + (void) fclose(dout); + } data = -1; pdata = -1; out: