From: Anton Moryakov Date: Wed, 5 Nov 2025 11:58:18 +0000 (+0300) Subject: dsaparam.c: Check return value of PEM_write_bio_PrivateKey() X-Git-Tag: 4.0-PRE-CLANG-FORMAT-WEBKIT~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34d3d2e308f82b222082e769aac53c190669956b;p=thirdparty%2Fopenssl.git dsaparam.c: Check return value of PEM_write_bio_PrivateKey() The result of PEM_write_bio_PrivateKey was not checked, which could lead to silent failure when writing a generated DSA private key to output. Now verify the return value and report an error if the write fails, matching the error handling pattern used for other write operations. Signed-off-by: Anton Moryakov Reviewed-by: Dmitry Belyavskiy Reviewed-by: Norbert Pocs (Merged from https://github.com/openssl/openssl/pull/29075) --- diff --git a/apps/dsaparam.c b/apps/dsaparam.c index 99fc3ee7b80..6cb0007aa3c 100644 --- a/apps/dsaparam.c +++ b/apps/dsaparam.c @@ -239,6 +239,11 @@ int dsaparam_main(int argc, char **argv) i = i2d_PrivateKey_bio(out, pkey); else i = PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, NULL); + if (i <= 0) { + BIO_printf(bio_err, + "Error, unable to write DSA private key\n"); + goto end; + } } ret = 0; end: