]> git.kaiwu.me - nginx.git/commitdiff
SSL: missing free calls in $ssl_client_s_dn and $ssl_client_i_dn.
authorNikolay Morozov <n.morozov@securitycode.ru>
Tue, 26 Mar 2019 06:33:57 +0000 (09:33 +0300)
committerNikolay Morozov <n.morozov@securitycode.ru>
Tue, 26 Mar 2019 06:33:57 +0000 (09:33 +0300)
If X509_get_issuer_name() or X509_get_subject_name() returned NULL,
this could lead to a certificate reference leak.  It cannot happen
in practice though, since each function returns an internal pointer
to a mandatory subfield of the certificate successfully decoded by
d2i_X509() during certificate message processing (closes #1751).

src/event/ngx_event_openssl.c

index bee264c9f29dba16192281f4a485c619943d81ad..7be4fb4cdb4a1d132c2e815dc376703f46125ffc 100644 (file)
@@ -4622,6 +4622,7 @@ ngx_ssl_get_subject_dn(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
 
     name = X509_get_subject_name(cert);
     if (name == NULL) {
+        X509_free(cert);
         return NGX_ERROR;
     }
 
@@ -4673,6 +4674,7 @@ ngx_ssl_get_issuer_dn(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
 
     name = X509_get_issuer_name(cert);
     if (name == NULL) {
+        X509_free(cert);
         return NGX_ERROR;
     }