From 34d3d2e308f82b222082e769aac53c190669956b Mon Sep 17 00:00:00 2001 From: Anton Moryakov Date: Wed, 5 Nov 2025 14:58:18 +0300 Subject: [PATCH] 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) --- apps/dsaparam.c | 5 +++++ 1 file changed, 5 insertions(+) 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: -- 2.47.3