Revamp SSH authentication code so that user interaction is more
[u/mdw/putty] / pscp.c
diff --git a/pscp.c b/pscp.c
index 9259dd0..575025f 100644 (file)
--- a/pscp.c
+++ b/pscp.c
@@ -213,8 +213,6 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
        if (pendsize < pendlen + len) {
            pendsize = pendlen + len + 4096;
            pending = sresize(pending, pendsize, unsigned char);
-           if (!pending)
-               fatalbox("Out of memory");
        }
        memcpy(pending + pendlen, p, len);
        pendlen += len;
@@ -222,6 +220,15 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
 
     return 0;
 }
+int from_backend_untrusted(void *frontend_handle, const char *data, int len)
+{
+    /*
+     * No "untrusted" output should get here (the way the code is
+     * currently, it's all diverted by FLAG_STDERR).
+     */
+    assert(!"Unexpected call to from_backend_untrusted()");
+    return 0; /* not reached */
+}
 static int ssh_scp_recv(unsigned char *buf, int len)
 {
     outptr = buf;
@@ -751,7 +758,7 @@ static struct fxp_handle *scp_sftp_filehandle;
 static struct fxp_xfer *scp_sftp_xfer;
 static uint64 scp_sftp_fileoffset;
 
-void scp_source_setup(char *target, int shouldbedir)
+int scp_source_setup(char *target, int shouldbedir)
 {
     if (using_sftp) {
        /*
@@ -766,7 +773,7 @@ void scp_source_setup(char *target, int shouldbedir)
        if (!fxp_init()) {
            tell_user(stderr, "unable to initialise SFTP: %s", fxp_error());
            errs++;
-           return;
+           return 1;
        }
 
        sftp_register(req = fxp_stat_send(target));
@@ -789,6 +796,7 @@ void scp_source_setup(char *target, int shouldbedir)
     } else {
        (void) response();
     }
+    return 0;
 }
 
 int scp_send_errmsg(char *str)
@@ -1980,7 +1988,8 @@ static void toremote(int argc, char *argv[])
     do_cmd(host, user, cmd);
     sfree(cmd);
 
-    scp_source_setup(targ, targetshouldbedirectory);
+    if (scp_source_setup(targ, targetshouldbedirectory))
+       return;
 
     for (i = 0; i < argc - 1; i++) {
        src = argv[i];
@@ -2204,7 +2213,6 @@ int psftp_main(int argc, char *argv[])
 #endif
        ;
     cmdline_tooltype = TOOLTYPE_FILETRANSFER;
-    ssh_get_line = &console_get_line;
     sk_init();
 
     /* Load Default Settings before doing anything else. */