}
strip_crlf(line);
if (0 == strncmp(line, "-----END ", 9) &&
- 0 == strcmp(line+strlen(line)-16, "PRIVATE KEY-----"))
+ 0 == strcmp(line+strlen(line)-16, "PRIVATE KEY-----")) {
+ sfree(line);
break; /* done */
+ }
if ((p = strchr(line, ':')) != NULL) {
if (headers_done) {
errmsg = "header found in body of key data";
goto error;
}
strip_crlf(line);
- if (!strcmp(line, "---- END SSH2 ENCRYPTED PRIVATE KEY ----"))
+ if (!strcmp(line, "---- END SSH2 ENCRYPTED PRIVATE KEY ----")) {
+ sfree(line);
break; /* done */
+ }
if ((p = strchr(line, ':')) != NULL) {
if (headers_done) {
errmsg = "header found in body of key data";
goto error;
}
+ fclose(fp);
if (errmsg_p) *errmsg_p = NULL;
return ret;
error:
+ if (fp)
+ fclose(fp);
+
if (line) {
smemclr(line, strlen(line));
sfree(line);
struct sshcom_key *key = load_sshcom_key(filename, NULL);
int pos, len, answer;
+ answer = 0;
+
*comment = NULL;
if (!key)
- return 0;
+ goto done;
/*
* Check magic number.
*/
- if (GET_32BIT(key->keyblob) != 0x3f6ff9eb)
- return 0; /* key is invalid */
+ if (GET_32BIT(key->keyblob) != 0x3f6ff9eb) {
+ goto done; /* key is invalid */
+ }
/*
* Find the cipher-type string.
*/
- answer = 0;
pos = 8;
if (key->keyblob_len < pos+4)
goto done; /* key is far too short */
answer = 1;
done:
- *comment = dupstr(key->comment);
+ *comment = dupstr(key ? key->comment : "");
smemclr(key->keyblob, key->keyblob_size);
sfree(key->keyblob);
smemclr(key, sizeof(*key));
pr->s = *s = new_connection(addr, dummy_realhost, port,
0, 1, 0, 0, (Plug) pr, conf);
+ sfree(dummy_realhost);
if ((err = sk_socket_error(*s)) != NULL) {
free_portfwd_private(pr);
return err;
conf_get_int(conf, CONF_addressfamily));
if (sk_addr_error(proxy_addr) != NULL) {
ret->error = "Proxy error: Unable to resolve proxy host name";
+ sfree(pplug);
return (Socket)ret;
}
sfree(proxy_canonical_name);
if (!wc_unescape(newsource, source)) {
/* Yes, here we go; it's a wildcard. Bah. */
char *dupsource, *lastpart, *dirpart, *wildcard;
+
+ sfree(newsource);
+
dupsource = dupstr(source);
lastpart = stripslashes(dupsource, 0);
wildcard = dupstr(lastpart);
return;
}
if (preserve) {
- if (scp_send_filetimes(mtime, atime))
+ if (scp_send_filetimes(mtime, atime)) {
+ close_rfile(f);
return;
+ }
}
if (verbose) {
uint64_decimal(size, sizestr);
tell_user(stderr, "Sending file %s, size=%s", last, sizestr);
}
- if (scp_send_filename(last, size, permissions))
+ if (scp_send_filename(last, size, permissions)) {
+ close_rfile(f);
return;
+ }
stat_bytes = uint64_make(0,0);
stat_starttime = time(NULL);
char *tmpdir;
int len, check;
+ sfree(unwcdir);
wildcard = stripslashes(dir, 0);
unwcdir = dupstr(dir);
len = wildcard - dir;
cmd->obey = sftp_cmd_quit;
if ((mode == 0) || (modeflags & 1))
printf("quit\n");
+ sfree(line);
return cmd; /* eof */
}
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
logevent(raw->frontend, msg);
+ sfree(msg);
}
static void raw_check_close(Raw raw)
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
logevent(rlogin->frontend, msg);
+ sfree(msg);
}
static int rlogin_closing(Plug plug, const char *error_msg, int error_code,
{
/* Remote side is trying to open a channel to talk to a
* forwarded port. Give them back a local channel number. */
- struct ssh_channel *c;
struct ssh_rportfwd pf, *pfp;
int remoteid;
int hostsize, port;
char *host;
const char *e;
- c = snew(struct ssh_channel);
- c->ssh = ssh;
remoteid = ssh_pkt_getuint32(pktin);
ssh_pkt_getstring(pktin, &host, &hostsize);
send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_FAILURE,
PKT_INT, remoteid, PKT_END);
} else {
+ struct ssh_channel *c = snew(struct ssh_channel);
+ c->ssh = ssh;
+
logeventf(ssh, "Received remote port open request for %s:%d",
pf.dhost, port);
e = pfd_newconnect(&c->u.pfd.s, pf.dhost, port,
freebn(w);
freebn(sha);
+ freebn(u1);
+ freebn(u2);
freebn(gu1p);
freebn(yu2p);
freebn(gu1yu2p);
ytest = modpow(dss->g, dss->x, dss->p);
if (0 != bignum_cmp(ytest, dss->y)) {
dss_freekey(dss);
+ freebn(ytest);
return NULL;
}
freebn(ytest);
if (commentptr)
*commentptr = comment;
+ else
+ sfree(comment);
fclose(fp);
if (!strcmp(b, "aes256-cbc"))
pm1 = copybn(key->p);
decbn(pm1);
ed = modmul(key->exponent, key->private_exponent, pm1);
+ freebn(pm1);
cmp = bignum_cmp(ed, One);
sfree(ed);
if (cmp != 0)
qm1 = copybn(key->q);
decbn(qm1);
ed = modmul(key->exponent, key->private_exponent, qm1);
+ freebn(qm1);
cmp = bignum_cmp(ed, One);
sfree(ed);
if (cmp != 0)
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
logevent(telnet->frontend, msg);
+ sfree(msg);
}
static int telnet_closing(Plug plug, const char *error_msg, int error_code,
p++;
}
- if (nstr < lenof(strings))
+ if (nstr < lenof(strings)) {
+ sfree(dupname);
return NULL; /* XLFD was malformed */
+ }
if (bold)
strings[2] = "bold";
4, 12, 5, 13, 6, 14, 7, 15
};
struct gui_data *inst = (struct gui_data *)data;
- char *title = dupcat(appname, " Reconfiguration", NULL);
+ char *title;
Conf *oldconf, *newconf;
int i, j, need_size;
else
inst->reconfiguring = TRUE;
+ title = dupcat(appname, " Reconfiguration", NULL);
+
oldconf = inst->conf;
newconf = conf_copy(inst->conf);
string_width("Could not change fonts in terminal window:"),
"OK", 'o', +1, 1,
NULL);
+ sfree(msgboxtext);
sfree(errmsg);
} else {
need_size = TRUE;
pid = fork();
if (pid < 0) {
perror("fork");
+ sfree(args);
return;
}
} else {
int status;
+ sfree(args);
waitpid(pid, &status, 0);
}
}
size_used = conf_deserialise(conf, data, size);
+ sfree(data);
if (use_pty_argv && size > size_used) {
int n = 0;
i = size_used;
ret = read(fd, buf+ngot, len-ngot);
if (ret < 0) {
close(fd);
+ sfree(buf);
perror("puttygen: unable to read /dev/random");
return NULL;
}
if (pid < 0) {
ret->error = dupprintf("fork: %s", strerror(errno));
+ sfree(cmd);
return (Socket)ret;
} else if (pid == 0) {
close(0);
{
char *msg = dupprintf("Opening serial device %s", line);
logevent(serial->frontend, msg);
+ sfree(msg);
}
serial->fd = open(line, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
ret = ssh_sftp_do_select(TRUE, no_fds_ok);
if (ret < 0) {
printf("connection died\n");
+ sfree(buf);
return NULL; /* woop woop */
}
if (ret > 0) {
ret = read(0, buf+buflen, 1);
if (ret < 0) {
perror("read");
+ sfree(buf);
return NULL;
}
if (ret == 0) {
/* eof on stdin; no error, but no answer either */
+ sfree(buf);
return NULL;
}
char *value = strchr(line, '=');
struct skeyval *kv;
- if (!value)
+ if (!value) {
+ sfree(line);
continue;
+ }
*value++ = '\0';
value[strcspn(value, "\r\n")] = '\0'; /* trim trailing NL */
int headerlen;
char *filename, *tmpfilename;
- newtext = dupprintf("%s@%d:%s %s\n", keytype, port, hostname, key);
- headerlen = 1 + strcspn(newtext, " "); /* count the space too */
-
/*
* Open both the old file and a new file.
*/
filename = make_filename(INDEX_HOSTKEYS, NULL);
rfp = fopen(filename, "r");
+ newtext = dupprintf("%s@%d:%s %s\n", keytype, port, hostname, key);
+ headerlen = 1 + strcspn(newtext, " "); /* count the space too */
+
/*
* Copy all lines from the old file to the new one that _don't_
* involve the same host key identifier as the one we're adding.
while ( (line = fgetline(rfp)) ) {
if (strncmp(line, newtext, headerlen))
fputs(line, wfp);
+ sfree(line);
}
fclose(rfp);
}
sk_addr_free(disp->addr);
sfree(disp->hostname);
sfree(disp->unixsocketpath);
+ sfree(disp);
return NULL; /* FIXME: report an error */
}
}
int len[4];
int family, protocol;
int ideal_match = FALSE;
- char *ourhostname = get_hostname();
+ char *ourhostname;
/*
* Normally we should look for precisely the details specified in
if (!authfp)
return;
+ ourhostname = get_hostname();
+
/* Records in .Xauthority contain four strings of up to 64K each */
buf = snewn(65537 * 4, char);