Correctly handle errors in CMS I/O code.
[openssl.git] / crypto / cms / cms_smime.c
index 8e3221b7269ed77427edee600bd8f9364abfaf34..dec8ef32f87d76df48866807bf01a9150fc4c6d7 100644 (file)
@@ -89,11 +89,13 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
                                if (!BIO_get_cipher_status(in))
                                        goto err;
                                }
+                       if (i < 0)
+                               goto err;
                        break;
                        }
                                
-               if (tmpout)
-                       BIO_write(tmpout, buf, i);
+               if (tmpout && (BIO_write(tmpout, buf, i) != i))
+                       goto err;
        }
 
        if(flags & CMS_TEXT)