1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Add an assortment of missing frees and closes.

Coverity's resource-leak checker is on the ball as usual.
This commit is contained in:
Simon Tatham 2017-02-14 20:42:26 +00:00
parent 33f4c8303f
commit 12a080874f
11 changed files with 37 additions and 0 deletions

View File

@ -1162,6 +1162,8 @@ void test(int retval, ...)
} else {
passes++;
}
sfree(argv);
}
void filecmp(char *file1, char *file2, char *fmt, ...)

View File

@ -406,6 +406,7 @@ void *pageant_handle_msg(const void *msg, int msglen, int *outlen,
if (i < 0) {
freebn(reqkey.exponent);
freebn(reqkey.modulus);
freebn(challenge);
fail_reason = "request truncated before challenge";
goto failure;
}
@ -1334,6 +1335,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
int n = rsa_public_blob_len(p, keylistlen);
if (n < 0) {
*retstr = dupstr("Received broken key list from agent");
sfree(keylist);
sfree(blob);
return PAGEANT_ACTION_FAILURE;
}
p += n;
@ -1342,6 +1345,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
int n;
if (keylistlen < 4) {
*retstr = dupstr("Received broken key list from agent");
sfree(keylist);
sfree(blob);
return PAGEANT_ACTION_FAILURE;
}
n = GET_32BIT(p);
@ -1350,6 +1355,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
if (n < 0 || n > keylistlen) {
*retstr = dupstr("Received broken key list from agent");
sfree(keylist);
sfree(blob);
return PAGEANT_ACTION_FAILURE;
}
p += n;
@ -1360,6 +1367,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
int n;
if (keylistlen < 4) {
*retstr = dupstr("Received broken key list from agent");
sfree(keylist);
sfree(blob);
return PAGEANT_ACTION_FAILURE;
}
n = GET_32BIT(p);
@ -1368,6 +1377,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
if (n < 0 || n > keylistlen) {
*retstr = dupstr("Received broken key list from agent");
sfree(keylist);
sfree(blob);
return PAGEANT_ACTION_FAILURE;
}
p += n;
@ -1414,6 +1425,7 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
* Run out of passphrases to try.
*/
*retstr = comment;
sfree(rkey);
return PAGEANT_ACTION_NEED_PP;
}
} else
@ -1437,6 +1449,7 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
* a bad passphrase.
*/
*retstr = dupstr(error);
sfree(rkey);
return PAGEANT_ACTION_FAILURE;
} else if (ret == 1) {
/*
@ -1514,12 +1527,19 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS) {
*retstr = dupstr("The already running Pageant "
"refused to add the key.");
freersakey(rkey);
sfree(rkey);
sfree(request);
sfree(response);
return PAGEANT_ACTION_FAILURE;
}
freersakey(rkey);
sfree(rkey);
sfree(request);
sfree(response);
} else {
if (!pageant_add_ssh1_key(rkey)) {
freersakey(rkey);
sfree(rkey); /* already present, don't waste RAM */
}
}
@ -1560,6 +1580,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS) {
*retstr = dupstr("The already running Pageant "
"refused to add the key.");
sfree(request);
sfree(response);
return PAGEANT_ACTION_FAILURE;
}

1
pscp.c
View File

@ -383,6 +383,7 @@ static void do_cmd(char *host, char *user, char *cmd)
/* Use `host' as a bare hostname. */
conf_set_str(conf, CONF_host, host);
}
conf_free(conf2);
} else {
/* Patch in hostname `host' to session details. */
conf_set_str(conf, CONF_host, host);

1
ssh.c
View File

@ -3954,6 +3954,7 @@ static void ssh_agentf_try_forward(struct ssh_channel *c)
* straight on and go round this loop again.
*/
ssh_agentf_got_response(c, reply, replylen);
sfree(reply);
}
/*

View File

@ -946,6 +946,7 @@ unsigned char *rfc4716_loadpub(FILE *fp, char **algorithm,
}
*q = '\0';
sfree(comment); /* *just* in case of multiple Comment headers */
comment = dupstr(line);
} else if (!strcmp(line, "Subject") ||
!strncmp(line, "x-", 2)) {

View File

@ -3304,6 +3304,7 @@ int do_config_box(const char *title, Conf *conf, int midsession,
dlg_cleanup(&dp);
sfree(selparams);
ctrl_free_box(ctrlbox);
return dp.retval;
}

View File

@ -1126,6 +1126,7 @@ static void x11font_enum_fonts(GtkWidget *widget,
}
}
XFreeFontNames(fontnames);
sfree(tmp);
}
static char *x11font_canonify_fontname(GtkWidget *widget, const char *name,

View File

@ -978,6 +978,8 @@ void run_agent(void)
fprintf(stderr, "pageant: %s: %s\n", socketname, strerror(errno));
exit(1);
}
conf_free(conf);
}
int main(int argc, char **argv)

View File

@ -58,6 +58,7 @@ void init_help(void)
HINSTANCE dllHH = load_system32_dll("hhctrl.ocx");
GET_WINDOWS_FUNCTION(dllHH, HtmlHelpA);
if (!p_HtmlHelpA) {
sfree(chm_path);
chm_path = NULL;
if (dllHH)
FreeLibrary(dllHH);

View File

@ -77,6 +77,10 @@ Socket platform_new_connection(SockAddr addr, const char *hostname,
Socket ret = new_error_socket
("Unable to create pipes for proxy command", plug);
sfree(cmd);
CloseHandle(us_from_cmd);
CloseHandle(cmd_to_us);
CloseHandle(us_to_cmd);
CloseHandle(cmd_from_us);
return ret;
}
}

View File

@ -220,6 +220,7 @@ static const char *serial_init(void *frontend_handle, void **backend_handle,
{
char *msg = dupprintf("Opening serial device %s", serline);
logevent(serial->frontend, msg);
sfree(msg);
}
{