diff options
author | Daiki Ueno <ueno@gnu.org> | 2021-03-16 05:42:45 +0000 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2021-03-16 05:42:45 +0000 |
commit | 32e048b4f3b2f936cfdb8c4b89f8bba75f92cd89 (patch) | |
tree | 70d2ce80225e4c628195545105ebc5edaebef7ac /doc | |
parent | 1def7f23104bd9160fc8373c2e5513ec9192e48f (diff) | |
parent | 1ff33c12aa1a8dc96f3e35cf690b0cafff00c151 (diff) | |
download | gnutls-32e048b4f3b2f936cfdb8c4b89f8bba75f92cd89.tar.gz |
Merge branch 'wip/dueno/coverity' into 'master'
Fix resource leaks spotted by coverity
See merge request gnutls/gnutls!1403
Diffstat (limited to 'doc')
-rw-r--r-- | doc/examples/ex-verify.c | 7 | ||||
-rw-r--r-- | doc/examples/tlsproxy/tlsproxy.c | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/doc/examples/ex-verify.c b/doc/examples/ex-verify.c index 623198793b..a4f6ebec9e 100644 --- a/doc/examples/ex-verify.c +++ b/doc/examples/ex-verify.c @@ -54,7 +54,7 @@ verify_certificate_chain(const char *hostname, CHECK(gnutls_x509_trust_list_add_crls(tlist, crl_list, crl_list_size, GNUTLS_TL_VERIFY_CRL, 0)); - cert = malloc(sizeof(*cert) * cert_chain_length); + cert = gnutls_calloc(cert_chain_length, sizeof(*cert)); assert(cert != NULL); /* Import all the certificates in the chain to @@ -104,6 +104,11 @@ verify_certificate_chain(const char *hostname, hostname); } + for (i = 0; i < cert_chain_length; i++) { + gnutls_x509_crt_deinit(cert[i]); + } + gnutls_free(cert); + gnutls_x509_trust_list_deinit(tlist, 1); return; diff --git a/doc/examples/tlsproxy/tlsproxy.c b/doc/examples/tlsproxy/tlsproxy.c index 9404d875ef..2607eae049 100644 --- a/doc/examples/tlsproxy/tlsproxy.c +++ b/doc/examples/tlsproxy/tlsproxy.c @@ -109,6 +109,7 @@ bindtoaddress (char *addrport) if (!rp) { fprintf (stderr, "Error binding to %s:%s: %m\n", addr, port); + freeaddrinfo (result); return -1; } @@ -172,6 +173,7 @@ connecttoaddress (char *addrport) if (!rp) { fprintf (stderr, "Error connecting to %s:%s: %m\n", addr, port); + freeaddrinfo (result); return -1; } @@ -341,26 +343,32 @@ processoptions (int argc, char **argv) break; case 'c': + free (connectaddr); connectaddr = strdup (optarg); break; case 'l': + free (listenaddr); listenaddr = strdup (optarg); break; case 'K': + free (keyfile); keyfile = strdup (optarg); break; case 'C': + free (certfile); certfile = strdup (optarg); break; case 'A': + free (cacertfile); cacertfile = strdup (optarg); break; case 'H': + free (hostname); hostname = strdup (optarg); break; |