Generate just one error code if iterated SSL_CTX_get() fails.
[oweals/openssl.git] / crypto / pkcs7 / pk7_smime.c
index 04489380b8f22d0634958ab91ca9fd52f518bcd4..058efcca2b75d36c8fdefc3db7b12fea9a326c18 100644 (file)
@@ -329,7 +329,6 @@ PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
        BIO *p7bio = NULL;
        int i;
        X509 *x509;
-       char inbuf[4096];
        static char txthdr[] = "Content-type: text/plain\r\n\r\n";
        if(!(p7 = PKCS7_new())) {
                PKCS7err(PKCS7_F_PKCS7_ENCRYPT,ERR_R_MALLOC_FAILURE);
@@ -362,11 +361,8 @@ PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
                }
        }
 
-       for (;;) {
-               i = BIO_read(in, inbuf, sizeof(inbuf));
-               if (i <= 0) break;
-               BIO_write(p7bio, inbuf, i);
-       }
+       SMIME_crlf_copy(in, p7bio, flags);
+
        BIO_flush(p7bio);
 
         if (!PKCS7_dataFinal(p7,p7bio)) {