From de97a44cb453eeb16f095052aedc7269b6eaba7b Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 2 Jul 2019 20:53:44 +0100 Subject: [PATCH] wmbiff: fixed leaks. Signed-off-by: Jeremy Sowden --- wmbiff/wmbiff/Imap4Client.c | 2 ++ wmbiff/wmbiff/passwordMgr.c | 5 +++++ wmbiff/wmbiff/test_tlscomm.c | 1 + wmbiff/wmbiff/tlsComm.c | 2 +- wmbiff/wmgeneral/wmgeneral.c | 6 +++--- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wmbiff/wmbiff/Imap4Client.c b/wmbiff/wmbiff/Imap4Client.c index 554d9c6..ca16171 100644 --- a/wmbiff/wmbiff/Imap4Client.c +++ b/wmbiff/wmbiff/Imap4Client.c @@ -200,6 +200,7 @@ FILE *imap_open(Pop3 *pc) mailboxes more often while remote things are unavailable or disconnected. */ } + free(connection_name); return NULL; } @@ -463,6 +464,7 @@ void imap_cacheHeaders( /*@notnull@ */ Pop3 *pc) pc->headerCache = m; pc->headerCache->in_use = 0; /* initialize that it isn't locked */ } else { + free(m); IMAP_DM(pc, DEBUG_ERROR, "error fetching: %s", hdrbuf); } if (!fetch_command_done) { diff --git a/wmbiff/wmbiff/passwordMgr.c b/wmbiff/wmbiff/passwordMgr.c index ec5d11b..3faabc3 100644 --- a/wmbiff/wmbiff/passwordMgr.c +++ b/wmbiff/wmbiff/passwordMgr.c @@ -213,6 +213,7 @@ char *passwordFor(const char *username, const char *servername, Pop3 *pc, { password_binding *p; + int p_allocked = 0; assert(username != NULL); assert(username[0] != '\0'); @@ -241,6 +242,7 @@ char *passwordFor(const char *username, const char *servername, Pop3 *pc, } } else { p = malloc(sizeof *p); + p_allocked = 1; } /* else, try to get it. */ @@ -282,6 +284,9 @@ char *passwordFor(const char *username, const char *servername, Pop3 *pc, return (retval); } + if (p_allocked) { + free(p); + } return (NULL); } diff --git a/wmbiff/wmbiff/test_tlscomm.c b/wmbiff/wmbiff/test_tlscomm.c index 5b89530..fec63f7 100644 --- a/wmbiff/wmbiff/test_tlscomm.c +++ b/wmbiff/wmbiff/test_tlscomm.c @@ -106,6 +106,7 @@ main(int argc __attribute__ ((unused)), char **argv memset(scs.unprocessed, 0, BUF_SIZE); printf("%d\n", tlscomm_expect(&scs, "prefix", buf, 255)); } + free(scs.name); return 0; } diff --git a/wmbiff/wmbiff/tlsComm.c b/wmbiff/wmbiff/tlsComm.c index e3b1601..58c1a30 100644 --- a/wmbiff/wmbiff/tlsComm.c +++ b/wmbiff/wmbiff/tlsComm.c @@ -386,9 +386,9 @@ static int tls_compare_certificates(const gnutls_datum_t * peercert) fd1 = fopen(certificate_filename, "r"); if (fd1 == NULL) { + free(b64_data_data); return 0; } - b64_data.size = fread(b64_data.data, 1, b64_data.size, fd1); fclose(fd1); diff --git a/wmbiff/wmgeneral/wmgeneral.c b/wmbiff/wmgeneral/wmgeneral.c index ddae0d7..0f8c267 100644 --- a/wmbiff/wmgeneral/wmgeneral.c +++ b/wmbiff/wmgeneral/wmgeneral.c @@ -119,8 +119,8 @@ void parse_rcfile(const char *filename, rckeys * keys) if (fp) { while (fgets(temp, 128, fp)) { key = 0; - q = strdup(temp); - q = strtok(q, tokens); + char *t = strdup(temp); + q = strtok(t, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { p = strstr(temp, keys[key].label); @@ -134,7 +134,7 @@ void parse_rcfile(const char *filename, rckeys * keys) } else key++; } - free(q); + free(t); } fclose(fp); }