|
From: | Rachid Koucha |
Subject: | [bug-inetutils] Re: Bug in inetutils-1.6: FTPD transfers files with a size of 0 |
Date: | Thu, 15 Jan 2009 23:38:40 +0100 |
User-agent: | Thunderbird 2.0.0.19 (X11/20090105) |
Hi, I made a patch for this issue. Please find attached the description of the patch in HTML format and the patch itself. Regards. Rachid Koucha a écrit : Hi, --
Tel: 0619838579 Mail: address@hidden WEB site: http://rachid.koucha.free.fr/ |
--- inetutils-1.6/ftpd/ftpd.c 2008-12-27 21:05:07.000000000 +0100 +++ inetutils-1.6-retr_size_0/ftpd/ftpd.c 2009-01-15 12:22:50.411041000 +0100 @@ -856,6 +856,9 @@ pass (const char *passwd) login_attempts = 0; /* This time successful. */ } + +#define FTPD_ST_BLKSIZE(st) ((st).st_blksize ? (st).st_blksize : 4096) + void retrieve (const char *cmd, const char *name) { @@ -867,7 +870,25 @@ retrieve (const char *cmd, const char *n if (cmd == 0) { fin = fopen (name, "r"), closefunc = fclose; - st.st_size = 0; + if (fin == NULL) + { + if (errno != 0) + { + perror_reply (550, name); + if (cmd == 0) + { + LOGCMD ("get", name); + } + } + return; + } + + if (fstat(fileno(fin), &st) < 0 || !S_ISREG (st.st_mode)) + { + reply (550, "%s: not a plain file.", name); + goto done; + } + buffer_size = FTPD_ST_BLKSIZE(st); } else { @@ -876,28 +897,25 @@ retrieve (const char *cmd, const char *n snprintf (line, sizeof line, cmd, name); name = line; fin = ftpd_popen (line, "r"), closefunc = ftpd_pclose; - st.st_size = -1; - buffer_size = BUFSIZ; - } - if (fin == NULL) - { - if (errno != 0) - { - perror_reply (550, name); - if (cmd == 0) + if (fin == NULL) + { + if (errno != 0) { - LOGCMD ("get", name); + perror_reply (550, name); + if (cmd == 0) + { + LOGCMD ("get", name); + } } - } - return; + return; + } + st.st_size = -1; + buffer_size = BUFSIZ; } + byte_count = -1; - if (cmd == 0 && (fstat (fileno (fin), &st) < 0 || !S_ISREG (st.st_mode))) - { - reply (550, "%s: not a plain file.", name); - goto done; - } + if (restart_point) { if (type == TYPE_A)Author: R. Koucha
[Prev in Thread] | Current Thread | [Next in Thread] |