diff --git a/Cryptlib/OpenSSL/crypto/pkcs7/pk7_smime.c b/Cryptlib/OpenSSL/crypto/pkcs7/pk7_smime.c index d6db27c..b0ff89a 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; }