ftp(1) is not handling write(2) errors correctly when sending files. The errors are ignored, and ftp(1) continues to read the source file and updates the progress bar.

To reproduce: start an FTP transfer using the put command. While the transfer is in progress, kill the server process handling the STOR.

OpenBSD 5.6/i386.

Here is a patch:

--- usr.bin/ftp/ftp.c.orig      Tue May 20 03:25:23 2014
+++ usr.bin/ftp/ftp.c   Wed Nov  5 18:20:24 2014
@@ -764,6 +764,8 @@ sendrequest(const char *cmd, const char *local, const
                                if ((d = write(fileno(dout), bufp, (size_t)c))
                                    <= 0)
                                        break;
+                       if (d < 0)
+                               break;
                        if (hash && (!progress || filesize < 0) ) {
                                while (bytes >= hashbytes) {
                                        (void)putc('#', ttyout);

Reply via email to