]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OpenSSL: Fix memory leak on FIPS error paths
authorJouni Malinen <j@w1.fi>
Thu, 16 Aug 2012 14:38:46 +0000 (17:38 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 16 Aug 2012 14:38:46 +0000 (17:38 +0300)
Do not leave the tls_global context allocated if the global OpenSSL
initialization fails. This was possible in case of FIPS builds if
the FIPS mode cannot be initialized.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/crypto/tls_openssl.c

index 19fa3fb14b771dd55d29f9165bd83ff69fc05c68..baf206ee929f6a47510c0139622f5a747e615b33 100644 (file)
@@ -709,6 +709,8 @@ void * tls_init(const struct tls_config *conf)
                                           "mode");
                                ERR_load_crypto_strings();
                                ERR_print_errors_fp(stderr);
+                               os_free(tls_global);
+                               tls_global = NULL;
                                return NULL;
                        } else
                                wpa_printf(MSG_INFO, "Running in FIPS mode");
@@ -717,6 +719,8 @@ void * tls_init(const struct tls_config *conf)
                if (conf && conf->fips_mode) {
                        wpa_printf(MSG_ERROR, "FIPS mode requested, but not "
                                   "supported");
+                       os_free(tls_global);
+                       tls_global = NULL;
                        return NULL;
                }
 #endif /* OPENSSL_FIPS */