summaryrefslogtreecommitdiff
path: root/imap/src/osdep/unix
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2021-08-23 21:16:46 -0600
committerEduardo Chappa <chappa@washington.edu>2021-08-23 21:16:46 -0600
commit8961761e0b3c7b3cc11a00f6ac6ebf7a29bc5a10 (patch)
tree277ebcf5150a1950dbd4deacb82cd89fbd9ce83f /imap/src/osdep/unix
parente9b3f2043f7d309ecc58b907ff17d561ff972698 (diff)
downloadalpine-8961761e0b3c7b3cc11a00f6ac6ebf7a29bc5a10.tar.xz
* Fix some memory leaks reported by Valgrind.
Diffstat (limited to 'imap/src/osdep/unix')
-rw-r--r--imap/src/osdep/unix/ssl_unix.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/imap/src/osdep/unix/ssl_unix.c b/imap/src/osdep/unix/ssl_unix.c
index b43842df..9d0124ff 100644
--- a/imap/src/osdep/unix/ssl_unix.c
+++ b/imap/src/osdep/unix/ssl_unix.c
@@ -468,16 +468,18 @@ static char *ssl_start_work (SSLSTREAM *stream,char *host,unsigned long flags)
if (SSL_write (stream->con,"",0) < 0)
return ssl_last_error ? ssl_last_error : "SSL negotiation failed";
/* need to validate host names? */
+ cert = SSL_get_peer_certificate (stream->con);
if (!(flags & NET_NOVALIDATECERT) &&
- (err = ssl_validate_cert (cert = SSL_get_peer_certificate (stream->con),
- host))) {
+ (err = ssl_validate_cert (cert, host))) {
/* application callback */
X509_NAME_oneline (X509_get_subject_name(cert), buf, sizeof(buf));
if (scq) return (*scq) (err,host,cert ? buf : "???") ? NIL : "";
/* error message to return via mm_log() */
sprintf (tmp,"*%.128s: %.255s",err,cert ? buf : "???");
+ X509_free(cert);
return ssl_last_error = cpystr (tmp);
}
+ X509_free(cert);
return NIL;
}
@@ -520,7 +522,7 @@ static char *ssl_validate_cert (X509 *cert,char *host)
{
int i,j,n, m = 0;
char *s=NULL,*t,*ret = NIL;
- void *ext;
+ void *ext = NIL;
GENERAL_NAME *name;
X509_NAME *cname;
X509_NAME_ENTRY *e;
@@ -546,6 +548,7 @@ static char *ssl_validate_cert (X509 *cert,char *host)
if ((name = sk_GENERAL_NAME_value (ext,i)) &&
(name->type = GEN_DNS) && (s = name->d.ia5->data) &&
ssl_compare_hostnames (host,s)) ret = NIL;
+ if(ext) GENERAL_NAMES_free(ext);
}
#endif /* OPENSSL_1_1_0 */
/* Method 2, use cname */
@@ -569,6 +572,7 @@ static char *ssl_validate_cert (X509 *cert,char *host)
if ((name = sk_GENERAL_NAME_value (ext,i)) &&
(name->type = GEN_DNS) && (s = name->d.ia5->data) &&
ssl_compare_hostnames (host,s)) ret = NIL;
+ if(ext) GENERAL_NAMES_free(ext);
}
}
}