+void cmdline_cleanup(void)
+{
+ int pri;
+
+ for (pri = 0; pri < NPRIORITIES; pri++)
+ sfree(saves[pri].params);
+}
+
#define SAVEABLE(pri) do { \
if (need_save) { cmdline_save_param(p, value, pri); return ret; } \
} while (0)
#define SAVEABLE(pri) do { \
if (need_save) { cmdline_save_param(p, value, pri); return ret; } \
} while (0)
static int psftp_connect(char *userhost, char *user, int portnumber);
static int do_sftp_init(void);
static int psftp_connect(char *userhost, char *user, int portnumber);
static int do_sftp_init(void);
/* ----------------------------------------------------------------------
* sftp client state.
/* ----------------------------------------------------------------------
* sftp client state.
*/
cmd->nwords = cmd->wordssize = 2;
cmd->words = sresize(cmd->words, cmd->wordssize, char *);
*/
cmd->nwords = cmd->wordssize = 2;
cmd->words = sresize(cmd->words, cmd->wordssize, char *);
- cmd->words[0] = "!";
- cmd->words[1] = p+1;
+ cmd->words[0] = dupstr("!");
+ cmd->words[1] = dupstr(p+1);
cmd->wordssize = cmd->nwords + 16;
cmd->words = sresize(cmd->words, cmd->wordssize, char *);
}
cmd->wordssize = cmd->nwords + 16;
cmd->words = sresize(cmd->words, cmd->wordssize, char *);
}
- cmd->words[cmd->nwords++] = q;
+ cmd->words[cmd->nwords++] = dupstr(q);
/*
* Now parse the first word and assign a function.
*/
/*
* Now parse the first word and assign a function.
*/
+void do_sftp_cleanup()
+{
+ char ch;
+ back->special(backhandle, TS_EOF);
+ sftp_recvdata(&ch, 1);
+ back->free(backhandle);
+ sftp_cleanup_request();
+ if (pwd) {
+ sfree(pwd);
+ pwd = NULL;
+ }
+ if (homedir) {
+ sfree(homedir);
+ homedir = NULL;
+ }
+}
+
void do_sftp(int mode, int modeflags, char *batchfile)
{
FILE *fp;
void do_sftp(int mode, int modeflags, char *batchfile)
{
FILE *fp;
cmd = sftp_getcmd(stdin, 0, 0);
if (!cmd)
break;
cmd = sftp_getcmd(stdin, 0, 0);
if (!cmd)
break;
- if (cmd->obey(cmd) < 0)
+ ret = cmd->obey(cmd);
+ if (cmd->words) {
+ int i;
+ for(i = 0; i < cmd->nwords; i++)
+ sfree(cmd->words[i]);
+ sfree(cmd->words);
+ }
+ sfree(cmd);
+ if (ret < 0)
}
if (verbose && realhost != NULL)
printf("Connected to %s\n", realhost);
}
if (verbose && realhost != NULL)
printf("Connected to %s\n", realhost);
+ if (realhost != NULL)
+ sfree(realhost);
* it now.
*/
if (userhost) {
* it now.
*/
if (userhost) {
- if (psftp_connect(userhost, user, portnumber))
+ int ret;
+ ret = psftp_connect(userhost, user, portnumber);
+ sfree(userhost);
+ if (ret)
return 1;
if (do_sftp_init())
return 1;
} else {
printf("psftp: no hostname specified; use \"open host.name\""
return 1;
if (do_sftp_init())
return 1;
} else {
printf("psftp: no hostname specified; use \"open host.name\""
}
do_sftp(mode, modeflags, batchfile);
}
do_sftp(mode, modeflags, batchfile);
sftp_recvdata(&ch, 1);
}
random_save_seed();
sftp_recvdata(&ch, 1);
}
random_save_seed();
+ cmdline_cleanup();
+ console_provide_logctx(NULL);
+ do_sftp_cleanup();
+ backhandle = NULL;
+ back = NULL;
+ sk_cleanup();
*/
int cmdline_process_param(char *, char *, int, Config *);
void cmdline_run_saved(Config *);
*/
int cmdline_process_param(char *, char *, int, Config *);
void cmdline_run_saved(Config *);
+void cmdline_cleanup(void);
extern char *cmdline_password;
#define TOOLTYPE_FILETRANSFER 1
#define TOOLTYPE_NONNETWORK 2
extern char *cmdline_password;
#define TOOLTYPE_FILETRANSFER 1
#define TOOLTYPE_NONNETWORK 2
if (gui_mode)
gui_send_errcount(list, errs);
if (gui_mode)
gui_send_errcount(list, errs);
+ cmdline_cleanup();
+ console_provide_logctx(NULL);
+ back->free(backhandle);
+ backhandle = NULL;
+ back = NULL;
+ sk_cleanup();
return (errs == 0 ? 0 : 1);
}
return (errs == 0 ? 0 : 1);
}
+void sftp_cleanup_request(void)
+{
+ if (sftp_requests == NULL) {
+ freetree234(sftp_requests);
+ sftp_requests = NULL;
+ }
+}
+
void sftp_register(struct sftp_request *req)
{
req->registered = 1;
void sftp_register(struct sftp_request *req)
{
req->registered = 1;
int sftp_senddata(char *data, int len);
int sftp_recvdata(char *data, int len);
int sftp_senddata(char *data, int len);
int sftp_recvdata(char *data, int len);
+/*
+ * Free sftp_requests
+ */
+void sftp_cleanup_request(void);
+
struct fxp_attrs {
unsigned long flags;
uint64 size;
struct fxp_attrs {
unsigned long flags;
uint64 size;
ssh->crcda_ctx = crcda_make_context();
logevent("Installing CRC compensation attack detector");
ssh->crcda_ctx = crcda_make_context();
logevent("Installing CRC compensation attack detector");
+ if (servkey.modulus) {
+ sfree(servkey.modulus);
+ servkey.modulus = NULL;
+ }
+ if (servkey.exponent) {
+ sfree(servkey.exponent);
+ servkey.exponent = NULL;
+ }
+ if (hostkey.modulus) {
+ sfree(hostkey.modulus);
+ hostkey.modulus = NULL;
+ }
+ if (hostkey.exponent) {
+ sfree(hostkey.exponent);
+ hostkey.exponent = NULL;
+ }
crWaitUntil(ispkt);
if (ssh->pktin.type != SSH1_SMSG_SUCCESS) {
crWaitUntil(ispkt);
if (ssh->pktin.type != SSH1_SMSG_SUCCESS) {
}
logevent("Sending password with camouflage packets");
ssh_pkt_defersend(ssh);
}
logevent("Sending password with camouflage packets");
ssh_pkt_defersend(ssh);
}
else if (!(ssh->remote_bugs & BUG_NEEDS_SSH1_PLAIN_PASSWORD)) {
/*
}
else if (!(ssh->remote_bugs & BUG_NEEDS_SSH1_PLAIN_PASSWORD)) {
/*
if (ssh->sccomp->text_name)
logeventf(ssh, "Initialised %s decompression",
ssh->sccomp->text_name);
if (ssh->sccomp->text_name)
logeventf(ssh, "Initialised %s decompression",
ssh->sccomp->text_name);
+ freebn(s->f);
+ freebn(s->g);
+ freebn(s->K);
+ freebn(s->p);
/*
* If this is the first key exchange phase, we must pass the
/*
* If this is the first key exchange phase, we must pass the
sfree(ssh->do_ssh1_login_state);
sfree(ssh->do_ssh2_transport_state);
sfree(ssh->do_ssh2_authconn_state);
sfree(ssh->do_ssh1_login_state);
sfree(ssh->do_ssh2_transport_state);
sfree(ssh->do_ssh2_authconn_state);
+ if (ssh->pktout.data) {
+ sfree(ssh->pktout.data);
+ ssh->pktout.data = NULL;
+ }
+ if (ssh->pktin.data) {
+ sfree(ssh->pktin.data);
+ ssh->pktin.data = NULL;
+ }
+ if (ssh->crcda_ctx) {
+ crcda_free_context(ssh->crcda_ctx);
+ ssh->crcda_ctx = NULL;
+ }
+ if (ssh->logctx) {
+ log_free(ssh->logctx);
+ ssh->logctx = NULL;
+ }
if (ssh->s)
ssh_do_close(ssh);
sfree(ssh);
if (ssh->s)
ssh_do_close(ssh);
sfree(ssh);
void crcda_free_context(void *handle)
{
void crcda_free_context(void *handle)
{
+ struct crcda_ctx *ctx = (struct crcda_ctx *)handle;
+ if (ctx) {
+ sfree(ctx->h);
+ ctx->h = NULL;
+ sfree(ctx);
+ }
}
static void crc_update(uint32 *a, void *b)
}
static void crc_update(uint32 *a, void *b)
if (bignum_byte(out, i) != hash[j])
ret = 0;
}
if (bignum_byte(out, i) != hash[j])
ret = 0;
}
for (i = 0; (s = index234(sktree, i)) != NULL; i++) {
p_closesocket(s->s);
}
for (i = 0; (s = index234(sktree, i)) != NULL; i++) {
p_closesocket(s->s);
}
+ freetree234(sktree);
+ sktree = NULL;