mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48: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:
parent
33f4c8303f
commit
12a080874f
2
cmdgen.c
2
cmdgen.c
@ -1162,6 +1162,8 @@ void test(int retval, ...)
|
|||||||
} else {
|
} else {
|
||||||
passes++;
|
passes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sfree(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void filecmp(char *file1, char *file2, char *fmt, ...)
|
void filecmp(char *file1, char *file2, char *fmt, ...)
|
||||||
|
22
pageant.c
22
pageant.c
@ -406,6 +406,7 @@ void *pageant_handle_msg(const void *msg, int msglen, int *outlen,
|
|||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
freebn(reqkey.exponent);
|
freebn(reqkey.exponent);
|
||||||
freebn(reqkey.modulus);
|
freebn(reqkey.modulus);
|
||||||
|
freebn(challenge);
|
||||||
fail_reason = "request truncated before challenge";
|
fail_reason = "request truncated before challenge";
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
@ -1334,6 +1335,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
|
|||||||
int n = rsa_public_blob_len(p, keylistlen);
|
int n = rsa_public_blob_len(p, keylistlen);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
*retstr = dupstr("Received broken key list from agent");
|
*retstr = dupstr("Received broken key list from agent");
|
||||||
|
sfree(keylist);
|
||||||
|
sfree(blob);
|
||||||
return PAGEANT_ACTION_FAILURE;
|
return PAGEANT_ACTION_FAILURE;
|
||||||
}
|
}
|
||||||
p += n;
|
p += n;
|
||||||
@ -1342,6 +1345,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
|
|||||||
int n;
|
int n;
|
||||||
if (keylistlen < 4) {
|
if (keylistlen < 4) {
|
||||||
*retstr = dupstr("Received broken key list from agent");
|
*retstr = dupstr("Received broken key list from agent");
|
||||||
|
sfree(keylist);
|
||||||
|
sfree(blob);
|
||||||
return PAGEANT_ACTION_FAILURE;
|
return PAGEANT_ACTION_FAILURE;
|
||||||
}
|
}
|
||||||
n = GET_32BIT(p);
|
n = GET_32BIT(p);
|
||||||
@ -1350,6 +1355,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
|
|||||||
|
|
||||||
if (n < 0 || n > keylistlen) {
|
if (n < 0 || n > keylistlen) {
|
||||||
*retstr = dupstr("Received broken key list from agent");
|
*retstr = dupstr("Received broken key list from agent");
|
||||||
|
sfree(keylist);
|
||||||
|
sfree(blob);
|
||||||
return PAGEANT_ACTION_FAILURE;
|
return PAGEANT_ACTION_FAILURE;
|
||||||
}
|
}
|
||||||
p += n;
|
p += n;
|
||||||
@ -1360,6 +1367,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
|
|||||||
int n;
|
int n;
|
||||||
if (keylistlen < 4) {
|
if (keylistlen < 4) {
|
||||||
*retstr = dupstr("Received broken key list from agent");
|
*retstr = dupstr("Received broken key list from agent");
|
||||||
|
sfree(keylist);
|
||||||
|
sfree(blob);
|
||||||
return PAGEANT_ACTION_FAILURE;
|
return PAGEANT_ACTION_FAILURE;
|
||||||
}
|
}
|
||||||
n = GET_32BIT(p);
|
n = GET_32BIT(p);
|
||||||
@ -1368,6 +1377,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
|
|||||||
|
|
||||||
if (n < 0 || n > keylistlen) {
|
if (n < 0 || n > keylistlen) {
|
||||||
*retstr = dupstr("Received broken key list from agent");
|
*retstr = dupstr("Received broken key list from agent");
|
||||||
|
sfree(keylist);
|
||||||
|
sfree(blob);
|
||||||
return PAGEANT_ACTION_FAILURE;
|
return PAGEANT_ACTION_FAILURE;
|
||||||
}
|
}
|
||||||
p += n;
|
p += n;
|
||||||
@ -1414,6 +1425,7 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
|
|||||||
* Run out of passphrases to try.
|
* Run out of passphrases to try.
|
||||||
*/
|
*/
|
||||||
*retstr = comment;
|
*retstr = comment;
|
||||||
|
sfree(rkey);
|
||||||
return PAGEANT_ACTION_NEED_PP;
|
return PAGEANT_ACTION_NEED_PP;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -1437,6 +1449,7 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
|
|||||||
* a bad passphrase.
|
* a bad passphrase.
|
||||||
*/
|
*/
|
||||||
*retstr = dupstr(error);
|
*retstr = dupstr(error);
|
||||||
|
sfree(rkey);
|
||||||
return PAGEANT_ACTION_FAILURE;
|
return PAGEANT_ACTION_FAILURE;
|
||||||
} else if (ret == 1) {
|
} 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) {
|
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS) {
|
||||||
*retstr = dupstr("The already running Pageant "
|
*retstr = dupstr("The already running Pageant "
|
||||||
"refused to add the key.");
|
"refused to add the key.");
|
||||||
|
freersakey(rkey);
|
||||||
|
sfree(rkey);
|
||||||
|
sfree(request);
|
||||||
|
sfree(response);
|
||||||
return PAGEANT_ACTION_FAILURE;
|
return PAGEANT_ACTION_FAILURE;
|
||||||
}
|
}
|
||||||
|
freersakey(rkey);
|
||||||
|
sfree(rkey);
|
||||||
sfree(request);
|
sfree(request);
|
||||||
sfree(response);
|
sfree(response);
|
||||||
} else {
|
} else {
|
||||||
if (!pageant_add_ssh1_key(rkey)) {
|
if (!pageant_add_ssh1_key(rkey)) {
|
||||||
|
freersakey(rkey);
|
||||||
sfree(rkey); /* already present, don't waste RAM */
|
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) {
|
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS) {
|
||||||
*retstr = dupstr("The already running Pageant "
|
*retstr = dupstr("The already running Pageant "
|
||||||
"refused to add the key.");
|
"refused to add the key.");
|
||||||
|
sfree(request);
|
||||||
|
sfree(response);
|
||||||
return PAGEANT_ACTION_FAILURE;
|
return PAGEANT_ACTION_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
pscp.c
1
pscp.c
@ -383,6 +383,7 @@ static void do_cmd(char *host, char *user, char *cmd)
|
|||||||
/* Use `host' as a bare hostname. */
|
/* Use `host' as a bare hostname. */
|
||||||
conf_set_str(conf, CONF_host, host);
|
conf_set_str(conf, CONF_host, host);
|
||||||
}
|
}
|
||||||
|
conf_free(conf2);
|
||||||
} else {
|
} else {
|
||||||
/* Patch in hostname `host' to session details. */
|
/* Patch in hostname `host' to session details. */
|
||||||
conf_set_str(conf, CONF_host, host);
|
conf_set_str(conf, CONF_host, host);
|
||||||
|
1
ssh.c
1
ssh.c
@ -3954,6 +3954,7 @@ static void ssh_agentf_try_forward(struct ssh_channel *c)
|
|||||||
* straight on and go round this loop again.
|
* straight on and go round this loop again.
|
||||||
*/
|
*/
|
||||||
ssh_agentf_got_response(c, reply, replylen);
|
ssh_agentf_got_response(c, reply, replylen);
|
||||||
|
sfree(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -946,6 +946,7 @@ unsigned char *rfc4716_loadpub(FILE *fp, char **algorithm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
|
sfree(comment); /* *just* in case of multiple Comment headers */
|
||||||
comment = dupstr(line);
|
comment = dupstr(line);
|
||||||
} else if (!strcmp(line, "Subject") ||
|
} else if (!strcmp(line, "Subject") ||
|
||||||
!strncmp(line, "x-", 2)) {
|
!strncmp(line, "x-", 2)) {
|
||||||
|
@ -3304,6 +3304,7 @@ int do_config_box(const char *title, Conf *conf, int midsession,
|
|||||||
|
|
||||||
dlg_cleanup(&dp);
|
dlg_cleanup(&dp);
|
||||||
sfree(selparams);
|
sfree(selparams);
|
||||||
|
ctrl_free_box(ctrlbox);
|
||||||
|
|
||||||
return dp.retval;
|
return dp.retval;
|
||||||
}
|
}
|
||||||
|
@ -1126,6 +1126,7 @@ static void x11font_enum_fonts(GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFreeFontNames(fontnames);
|
XFreeFontNames(fontnames);
|
||||||
|
sfree(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *x11font_canonify_fontname(GtkWidget *widget, const char *name,
|
static char *x11font_canonify_fontname(GtkWidget *widget, const char *name,
|
||||||
|
@ -978,6 +978,8 @@ void run_agent(void)
|
|||||||
fprintf(stderr, "pageant: %s: %s\n", socketname, strerror(errno));
|
fprintf(stderr, "pageant: %s: %s\n", socketname, strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conf_free(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -58,6 +58,7 @@ void init_help(void)
|
|||||||
HINSTANCE dllHH = load_system32_dll("hhctrl.ocx");
|
HINSTANCE dllHH = load_system32_dll("hhctrl.ocx");
|
||||||
GET_WINDOWS_FUNCTION(dllHH, HtmlHelpA);
|
GET_WINDOWS_FUNCTION(dllHH, HtmlHelpA);
|
||||||
if (!p_HtmlHelpA) {
|
if (!p_HtmlHelpA) {
|
||||||
|
sfree(chm_path);
|
||||||
chm_path = NULL;
|
chm_path = NULL;
|
||||||
if (dllHH)
|
if (dllHH)
|
||||||
FreeLibrary(dllHH);
|
FreeLibrary(dllHH);
|
||||||
|
@ -77,6 +77,10 @@ Socket platform_new_connection(SockAddr addr, const char *hostname,
|
|||||||
Socket ret = new_error_socket
|
Socket ret = new_error_socket
|
||||||
("Unable to create pipes for proxy command", plug);
|
("Unable to create pipes for proxy command", plug);
|
||||||
sfree(cmd);
|
sfree(cmd);
|
||||||
|
CloseHandle(us_from_cmd);
|
||||||
|
CloseHandle(cmd_to_us);
|
||||||
|
CloseHandle(us_to_cmd);
|
||||||
|
CloseHandle(cmd_from_us);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,6 +220,7 @@ static const char *serial_init(void *frontend_handle, void **backend_handle,
|
|||||||
{
|
{
|
||||||
char *msg = dupprintf("Opening serial device %s", serline);
|
char *msg = dupprintf("Opening serial device %s", serline);
|
||||||
logevent(serial->frontend, msg);
|
logevent(serial->frontend, msg);
|
||||||
|
sfree(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user