summaryrefslogtreecommitdiff
path: root/Cryptlib
diff options
context:
space:
mode:
authorMatthew Garrett <matthew.garrett@nebula.com>2013-10-04 11:51:09 -0400
committerPeter Jones <pjones@redhat.com>2013-10-04 11:51:09 -0400
commit4bf7fb2ef1ed13251efad3928d41e5eaf2f4aaa4 (patch)
treed1a78d5038554f77e72138fd25649477faf03d9c /Cryptlib
parenta3beb2a6f7b9ba6af08318355f66f3438770f15d (diff)
downloadefi-boot-shim-4bf7fb2ef1ed13251efad3928d41e5eaf2f4aaa4.tar.gz
efi-boot-shim-4bf7fb2ef1ed13251efad3928d41e5eaf2f4aaa4.zip
Add Tiano patch e98e59c237e17f064a4ecffb39d45499f89720a1
This is: Fix a bug in OpensslLib that PKCS7_verify will use over 8k stack space. Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Dong Guo <guo.dong@intel.com> from upstream.
Diffstat (limited to 'Cryptlib')
-rwxr-xr-xCryptlib/OpenSSL/crypto/pkcs7/pk7_smime.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Cryptlib/OpenSSL/crypto/pkcs7/pk7_smime.c b/Cryptlib/OpenSSL/crypto/pkcs7/pk7_smime.c
index d6db27c6..b0ff89aa 100755
--- a/Cryptlib/OpenSSL/crypto/pkcs7/pk7_smime.c
+++ b/Cryptlib/OpenSSL/crypto/pkcs7/pk7_smime.c
@@ -176,7 +176,8 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
PKCS7_SIGNER_INFO *si;
X509_STORE_CTX cert_ctx;
- char buf[4096];
+ char *buf = NULL;
+ int bufsiz;
int i, j=0, k, ret = 0;
BIO *p7bio;
BIO *tmpin, *tmpout;
@@ -287,10 +288,16 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
BIO_set_mem_eof_return(tmpout, 0);
} else tmpout = out;
+ bufsiz = 4096;
+ buf = OPENSSL_malloc (bufsiz);
+ if (buf == NULL) {
+ goto err;
+ }
+
/* We now have to 'read' from p7bio to calculate digests etc. */
for (;;)
{
- i=BIO_read(p7bio,buf,sizeof(buf));
+ i=BIO_read(p7bio,buf,bufsiz);
if (i <= 0) break;
if (tmpout) BIO_write(tmpout, buf, i);
}
@@ -329,6 +336,10 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
sk_X509_free(signers);
+ if (buf != NULL) {
+ OPENSSL_free (buf);
+ }
+
return ret;
}