Initialise CMS signature buffer length properly.
authorDr. Stephen Henson <steve@openssl.org>
Tue, 2 Jul 2013 21:11:27 +0000 (22:11 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 2 Jul 2013 21:12:19 +0000 (22:12 +0100)
crypto/cms/cms_sd.c

index b7dbf52ab1ef0d5908658a3e9080cf756c52348b..8f672890a076f6089b7ef41ab988e025c0f0533a 100644 (file)
@@ -700,7 +700,8 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms,
                pctx = si->pctx;
                if (!EVP_DigestFinal_ex(&mctx, md, &mdlen))
                        goto err;
                pctx = si->pctx;
                if (!EVP_DigestFinal_ex(&mctx, md, &mdlen))
                        goto err;
-               sig = OPENSSL_malloc(EVP_PKEY_size(si->pkey));
+               siglen = EVP_PKEY_size(si->pkey);
+               sig = OPENSSL_malloc(siglen);
                if (!sig)
                        {
                        CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN,
                if (!sig)
                        {
                        CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN,