X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=psftp.c;h=094e68b0ce417b3d9cac3ed40894ce33194991c3;hb=fdbd6978016e9fd87db7b3bfc33ff0da8bd3eea9;hp=302e1a73f3b30f9f4adbbd44f4873f116e9e3ed0;hpb=466b1c82d5db5d2f71daf7e2f0a450c9ff9cadd6;p=PuTTY.git diff --git a/psftp.c b/psftp.c index 302e1a73..094e68b0 100644 --- a/psftp.c +++ b/psftp.c @@ -25,7 +25,7 @@ */ static int psftp_connect(char *userhost, char *user, int portnumber); -static void do_sftp_init(void); +static int do_sftp_init(void); /* ---------------------------------------------------------------------- * sftp client state. @@ -1361,7 +1361,7 @@ struct sftp_command *sftp_getcmd(FILE *fp, int mode, int modeflags) return cmd; } -static void do_sftp_init(void) +static int do_sftp_init(void) { /* * Do protocol initialisation. @@ -1369,7 +1369,7 @@ static void do_sftp_init(void) if (!fxp_init()) { fprintf(stderr, "Fatal: unable to initialise SFTP: %s\n", fxp_error()); - return; + return 1; /* failure */ } /* @@ -1385,6 +1385,7 @@ static void do_sftp_init(void) printf("Remote working directory is %s\n", homedir); } pwd = dupstr(homedir); + return 0; } void do_sftp(int mode, int modeflags, char *batchfile) @@ -1511,6 +1512,8 @@ int from_backend(int is_stderr, char *data, int datalen) unsigned char *p = (unsigned char *) data; unsigned len = (unsigned) datalen; + assert(len > 0); + /* * stderr data is just spouted to local stderr and otherwise * ignored. @@ -1847,7 +1850,8 @@ int main(int argc, char *argv[]) if (userhost) { if (psftp_connect(userhost, user, portnumber)) return 1; - do_sftp_init(); + if (do_sftp_init()) + return 1; } else { printf("psftp: no hostname specified; use \"open host.name\"" " to connect\n");