]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
PEM_write_bio_ASN1_stream(): complete I/O error checking
authorDr. David von Oheimb <dev@ddvo.net>
Mon, 14 Apr 2025 09:22:30 +0000 (11:22 +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)

crypto/asn1/asn_mime.c

index 40221d390127e8d92060117e81474a562a09fbcf..22d4d137b7c5520467a1ca7e3a24af34a599af05 100644 (file)
@@ -128,11 +128,9 @@ static int B64_write_ASN1(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
 int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
                               const char *hdr, const ASN1_ITEM *it)
 {
-    int r;
-    BIO_printf(out, "-----BEGIN %s-----\n", hdr);
-    r = B64_write_ASN1(out, val, in, flags, it);
-    BIO_printf(out, "-----END %s-----\n", hdr);
-    return r;
+    return BIO_printf(out, "-----BEGIN %s-----\n", hdr) >= 0
+        && B64_write_ASN1(out, val, in, flags, it)
+        && BIO_printf(out, "-----END %s-----\n", hdr) >= 0;
 }
 
 static ASN1_VALUE *b64_read_asn1(BIO *bio, const ASN1_ITEM *it, ASN1_VALUE **x,