Fix potential cert memory leak in check_certificate_by_digest().
authorKevin McCarthy <kevin@8t8.us>
Sun, 12 Feb 2017 20:24:51 +0000 (12:24 -0800)
committerRichard Russon <rich@flatcap.org>
Mon, 20 Feb 2017 16:49:41 +0000 (16:49 +0000)
Thanks to Matthias Andree's debugging, it appears the cert is not
freed when PEM_read_X509() encounters EOF.  Change the return value
check to not overwrite cert.  It is already updated via the second
parameter.

mutt_ssl.c

index 3d310b2b0bc6146e358bfeb14da8282107e8a867..fbda79970cc572d5251d23fc6c317f175d1eb654 100644 (file)
@@ -776,7 +776,7 @@ static int check_certificate_by_digest (X509 *peercert)
     return 0;
   }
 
-  while ((cert = PEM_read_X509 (fp, &cert, NULL, NULL)) != NULL)
+  while (PEM_read_X509 (fp, &cert, NULL, NULL) != NULL)
   {
     pass = compare_certificates (cert, peercert, peermd, peermdlen) ? 0 : 1;