]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps/cms.c: add failure handling for I/O errors of 'BIO_printf(out, ...)'
authorDr. David von Oheimb <dev@ddvo.net>
Mon, 14 Apr 2025 09:10:52 +0000 (11:10 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Wed, 14 May 2025 06:43:21 +0000 (08:43 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/27368)

apps/cms.c

index 7af43a2afc47ec504ac1f58694e87e557eb4bb99..8c7feed431280f995af4d48e21dd6d6f04b2b83b 100644 (file)
@@ -1261,12 +1261,12 @@ int cms_main(int argc, char **argv)
             }
             ret = 1;
         } else if (outformat == FORMAT_SMIME) {
-            if (to)
-                BIO_printf(out, "To: %s%s", to, mime_eol);
-            if (from)
-                BIO_printf(out, "From: %s%s", from, mime_eol);
-            if (subject)
-                BIO_printf(out, "Subject: %s%s", subject, mime_eol);
+            if (to != NULL && BIO_printf(out, "To: %s%s", to, mime_eol) < 0)
+                goto end;
+            if (from != NULL && BIO_printf(out, "From: %s%s", from, mime_eol) < 0)
+                goto end;
+            if (subject != NULL && BIO_printf(out, "Subject: %s%s", subject, mime_eol) < 0)
+                goto end;
             if (operation == SMIME_RESIGN)
                 ret = SMIME_write_CMS(out, cms, indata, flags);
             else