]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - pscp.c
first pass
[PuTTY.git] / pscp.c
diff --git a/pscp.c b/pscp.c
index 150b5492b8948b3a90b0a17895970f58ab081df2..454ec084c5cf5d161d713ed2f643e5dc4429bee2 100644 (file)
--- a/pscp.c
+++ b/pscp.c
@@ -1560,6 +1560,12 @@ int scp_recv_filedata(char *data, int len)
        }
 
        if (xfer_download_data(scp_sftp_xfer, &vbuf, &actuallen)) {
+            if (actuallen <= 0) {
+                tell_user(stderr, "pscp: end of file while reading");
+                errs++;
+                sfree(vbuf);
+                return -1;
+            }
            /*
             * This assertion relies on the fact that the natural
             * block size used in the xfer manager is at most that
@@ -1963,8 +1969,10 @@ static void sink(const char *targ, const char *src)
            read = scp_recv_filedata(transbuf, (int)blksize.lo);
            if (read <= 0)
                bump("Lost connection");
-           if (wrerror)
+           if (wrerror) {
+                received = uint64_add32(received, read);
                continue;
+            }
            if (write_to_file(f, transbuf, read) != (int)read) {
                wrerror = 1;
                /* FIXME: in sftp we can actually abort the transfer */
@@ -1972,6 +1980,7 @@ static void sink(const char *targ, const char *src)
                    printf("\r%-25.25s | %50s\n",
                           stat_name,
                           "Write error.. waiting for end of file");
+                received = uint64_add32(received, read);
                continue;
            }
            if (statistics) {