mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Fix silly segfault due to PSFTP thinking connection is fine even if
fxp_init() fails to get initial packet. [originally from svn r1565]
This commit is contained in:
parent
4f33c36ff5
commit
98dd3cb9f2
8
psftp.c
8
psftp.c
@ -1361,7 +1361,7 @@ struct sftp_command *sftp_getcmd(FILE *fp, int mode, int modeflags)
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_sftp_init(void)
|
static int do_sftp_init(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Do protocol initialisation.
|
* Do protocol initialisation.
|
||||||
@ -1369,7 +1369,7 @@ static void do_sftp_init(void)
|
|||||||
if (!fxp_init()) {
|
if (!fxp_init()) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Fatal: unable to initialise SFTP: %s\n", fxp_error());
|
"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);
|
printf("Remote working directory is %s\n", homedir);
|
||||||
}
|
}
|
||||||
pwd = dupstr(homedir);
|
pwd = dupstr(homedir);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_sftp(int mode, int modeflags, char *batchfile)
|
void do_sftp(int mode, int modeflags, char *batchfile)
|
||||||
@ -1847,7 +1848,8 @@ int main(int argc, char *argv[])
|
|||||||
if (userhost) {
|
if (userhost) {
|
||||||
if (psftp_connect(userhost, user, portnumber))
|
if (psftp_connect(userhost, user, portnumber))
|
||||||
return 1;
|
return 1;
|
||||||
do_sftp_init();
|
if (do_sftp_init())
|
||||||
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
printf("psftp: no hostname specified; use \"open host.name\""
|
printf("psftp: no hostname specified; use \"open host.name\""
|
||||||
" to connect\n");
|
" to connect\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user