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 <ant.v.moryakov@gmail.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29075)
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: