dev_crypto_cipher: return immediately if allocating cin/cout failed
authorJonas Maebe <jonas.maebe@elis.ugent.be>
Sun, 8 Dec 2013 17:09:58 +0000 (18:09 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Sun, 17 Aug 2014 16:51:35 +0000 (18:51 +0200)
Signed-off-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/evp/openbsd_hw.c

index 93ed5d65156ef714d18a8157ed29c562e45a778f..0554019489e7c40c24e738a534715d3dcafb1a9f 100644 (file)
@@ -193,6 +193,8 @@ static int dev_crypto_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
            if(((unsigned long)in&3) || cinl != inl)
                {
                cin=OPENSSL_malloc(cinl);
+               if (cin == NULL)
+                   return 0;
                memcpy(cin,in,inl);
                cryp.src=cin;
                }
@@ -200,6 +202,12 @@ static int dev_crypto_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
            if(((unsigned long)out&3) || cinl != inl)
                {
                cout=OPENSSL_malloc(cinl);
+               if (cout == NULL)
+                   {
+                   if (cin != NULL)
+                       OPENSSL_free(cin);
+                   return 0;
+                   }
                cryp.dst=cout;
                }