]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
scp_recv_filedata: handle EOF more sensibly.
authorSimon Tatham <anakin@pobox.com>
Wed, 15 Feb 2017 21:39:23 +0000 (21:39 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 15 Feb 2017 21:39:23 +0000 (21:39 +0000)
xfer_download_data could return actuallen as either 0 or -1 to
indicate EOF. Now it's always 0, and scp_recv_filedata actually checks
for that case and reports an error.

pscp.c
sftp.c

diff --git a/pscp.c b/pscp.c
index 150b5492b8948b3a90b0a17895970f58ab081df2..f7e09db959ccd1d60bdd4163f70b156aa0b265ce 100644 (file)
--- a/pscp.c
+++ b/pscp.c
@@ -1560,6 +1560,13 @@ int scp_recv_filedata(char *data, int len)
        }
 
        if (xfer_download_data(scp_sftp_xfer, &vbuf, &actuallen)) {
+            if (actuallen <= 0) {
+                tell_user(stderr, "pscp: %s while reading",
+                          actuallen < 0 ? "error" : "end of file");
+                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
diff --git a/sftp.c b/sftp.c
index 5685c79ea7a68c2b02945c54cef15721efc72a8a..dbbd740109c2efedb90c7e4113021e3805c6fd12 100644 (file)
--- a/sftp.c
+++ b/sftp.c
@@ -1226,6 +1226,7 @@ int xfer_download_gotpkt(struct fxp_xfer *xfer, struct sftp_packet *pktin)
 
     if ((rr->retlen < 0 && fxp_error_type()==SSH_FX_EOF) || rr->retlen == 0) {
        xfer->eof = TRUE;
+        rr->retlen = 0;
        rr->complete = -1;
 #ifdef DEBUG_DOWNLOAD
        printf("setting eof\n");