]> 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 126c2ad64d75d0f8a2964e832c314354091b4ffe..454ec084c5cf5d161d713ed2f643e5dc4429bee2 100644 (file)
--- a/pscp.c
+++ b/pscp.c
@@ -383,6 +383,7 @@ static void do_cmd(char *host, char *user, char *cmd)
            /* Use `host' as a bare hostname. */
            conf_set_str(conf, CONF_host, host);
        }
+        conf_free(conf2);
     } else {
        /* Patch in hostname `host' to session details. */
        conf_set_str(conf, CONF_host, host);
@@ -698,7 +699,8 @@ void scp_sftp_listdir(const char *dirname)
     dirh = fxp_opendir_recv(pktin, req);
 
     if (dirh == NULL) {
-       printf("Unable to open %s: %s\n", dirname, fxp_error());
+               tell_user(stderr, "Unable to open %s: %s\n", dirname, fxp_error());
+               errs++;
     } else {
        nnames = namesize = 0;
        ournames = NULL;
@@ -1558,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
@@ -1961,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 */
@@ -1970,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) {
@@ -2244,6 +2255,8 @@ static void usage(void)
     printf("  -hostkey aa:bb:cc:...\n");
     printf("            manually specify a host key (may be repeated)\n");
     printf("  -batch    disable all interactive prompts\n");
+    printf("  -proxycmd command\n");
+    printf("            use 'command' as local proxy\n");
     printf("  -unsafe   allow server-side wildcards (DANGEROUS)\n");
     printf("  -sftp     force use of SFTP protocol\n");
     printf("  -scp      force use of SCP protocol\n");
@@ -2269,7 +2282,7 @@ void version(void)
     char *buildinfo_text = buildinfo("\n");
     printf("pscp: %s\n%s\n", ver, buildinfo_text);
     sfree(buildinfo_text);
-    cleanup_exit(1);
+    exit(0);
 }
 
 void cmdline_error(const char *p, ...)