old_hmac_encode: check for NULL result when allocating *pder
[openssl.git] / crypto / hmac / hm_ameth.c
index 9f6b65abb57e604ebe84c148f9d6fc1323724463..3d998e94da861f0ea20a17a324d927614b10134d 100644 (file)
@@ -104,7 +104,7 @@ static int hmac_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
  */
 
 static int old_hmac_decode(EVP_PKEY *pkey,
  */
 
 static int old_hmac_decode(EVP_PKEY *pkey,
-                          const unsigned char **pder, size_t derlen)
+                                       const unsigned char **pder, int derlen)
        {
        ASN1_OCTET_STRING *os;
        os = ASN1_OCTET_STRING_new();
        {
        ASN1_OCTET_STRING *os;
        os = ASN1_OCTET_STRING_new();
@@ -123,6 +123,8 @@ static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder)
                if (!*pder)
                        {
                        *pder = OPENSSL_malloc(os->length);
                if (!*pder)
                        {
                        *pder = OPENSSL_malloc(os->length);
+                       if (*pder == NULL)
+                               return -1;
                        inc = 0;
                        }
                else inc = 1;
                        inc = 0;
                        }
                else inc = 1;
@@ -152,8 +154,8 @@ const EVP_PKEY_ASN1_METHOD hmac_asn1_meth =
        0,0,0,
 
        hmac_size,
        0,0,0,
 
        hmac_size,
-       0,
-       0,0,0,0,0,0,
+       0, 0,
+       0,0,0,0,0,0,0,
 
        hmac_key_free,
        hmac_pkey_ctrl,
 
        hmac_key_free,
        hmac_pkey_ctrl,