Fix memory leak on invalid CertificateRequest.
authorDavid Benjamin <davidben@google.com>
Mon, 14 Mar 2016 19:03:07 +0000 (15:03 -0400)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 7 Apr 2016 18:25:48 +0000 (19:25 +0100)
Free up parsed X509_NAME structure if the CertificateRequest message
contains excess data.

The security impact is considered insignificant. This is a client side
only leak and a large number of connections to malicious servers would
be needed to have a significant impact.

This was found by libFuzzer.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Stephen Henson <steve@openssl.org>
ssl/s3_clnt.c

index 04cc9f54a92dff51ba1ec263117c8b702430ca87..19dc8648b952dd2dac0b8b3ff879049fa5dd9c35 100644 (file)
@@ -2199,6 +2199,7 @@ int ssl3_get_certificate_request(SSL *s)
             SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE);
             goto err;
         }
+        xn = NULL;
 
         p += l;
         nc += l + 2;
@@ -2222,6 +2223,7 @@ int ssl3_get_certificate_request(SSL *s)
  err:
     s->state = SSL_ST_ERR;
  done:
+    X509_NAME_free(xn);
     if (ca_sk != NULL)
         sk_X509_NAME_pop_free(ca_sk, X509_NAME_free);
     return (ret);