aes_gcm_cleanup() should check that gctx != NULL before
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 1 Jan 2017 13:53:33 +0000 (14:53 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 7 Feb 2017 09:19:16 +0000 (09:19 +0000)
calling OPENSSL_cleanse()

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2149)

crypto/evp/e_aes.c

index 7c62d327a1f61338016add658f32076663eca9ad..47fcd82077fad5fa13ed3eb09088a2ffd602ed89 100644 (file)
@@ -1120,6 +1120,8 @@ BLOCK_CIPHER_generic_pack(NID_aes, 128, EVP_CIPH_FLAG_FIPS)
 static int aes_gcm_cleanup(EVP_CIPHER_CTX *c)
 {
     EVP_AES_GCM_CTX *gctx = c->cipher_data;
+    if (gctx == NULL)
+        return 0;
     OPENSSL_cleanse(&gctx->gcm, sizeof(gctx->gcm));
     if (gctx->iv != c->iv)
         OPENSSL_free(gctx->iv);