X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fpkey.c;h=0806b4e045bddd0f7a6e54f0f42cfa51295c0421;hb=b754a8a1590b8c5c9662c8a0ba49573991488b20;hp=0e961dd95e211b20d17af58c7f398b3410023e2a;hpb=dab2cd68e7cc304c9b1a4e7cee18a98711771a53;p=oweals%2Fopenssl.git diff --git a/apps/pkey.c b/apps/pkey.c index 0e961dd95e..0806b4e045 100644 --- a/apps/pkey.c +++ b/apps/pkey.c @@ -1,7 +1,7 @@ /* - * Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. * - * Licensed under the OpenSSL license (the "License"). You may not use + * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html @@ -186,23 +186,29 @@ int pkey_main(int argc, char **argv) if (!noout) { if (outformat == FORMAT_PEM) { if (pubout) { - PEM_write_bio_PUBKEY(out, pkey); + if (!PEM_write_bio_PUBKEY(out, pkey)) + goto end; } else { assert(private); - if (traditional) - PEM_write_bio_PrivateKey_traditional(out, pkey, cipher, - NULL, 0, NULL, - passout); - else - PEM_write_bio_PrivateKey(out, pkey, cipher, - NULL, 0, NULL, passout); + if (traditional) { + if (!PEM_write_bio_PrivateKey_traditional(out, pkey, cipher, + NULL, 0, NULL, + passout)) + goto end; + } else { + if (!PEM_write_bio_PrivateKey(out, pkey, cipher, + NULL, 0, NULL, passout)) + goto end; + } } } else if (outformat == FORMAT_ASN1) { if (pubout) { - i2d_PUBKEY_bio(out, pkey); + if (!i2d_PUBKEY_bio(out, pkey)) + goto end; } else { assert(private); - i2d_PrivateKey_bio(out, pkey); + if (!i2d_PrivateKey_bio(out, pkey)) + goto end; } } else { BIO_printf(bio_err, "Bad format specified for key\n"); @@ -212,10 +218,12 @@ int pkey_main(int argc, char **argv) if (text) { if (pubtext) { - EVP_PKEY_print_public(out, pkey, 0, NULL); + if (EVP_PKEY_print_public(out, pkey, 0, NULL) <= 0) + goto end; } else { assert(private); - EVP_PKEY_print_private(out, pkey, 0, NULL); + if (EVP_PKEY_print_private(out, pkey, 0, NULL) <= 0) + goto end; } }