Simplify x509.c slightly by using X509_get0_pubkey() instead of
authortb <tb@openbsd.org>
Sun, 12 Dec 2021 20:29:15 +0000 (20:29 +0000)
committertb <tb@openbsd.org>
Sun, 12 Dec 2021 20:29:15 +0000 (20:29 +0000)
X509_get_pubkey()

ok inoguchi

usr.bin/openssl/x509.c

index 3883872..5248c67 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509.c,v 1.27 2021/12/12 20:28:02 tb Exp $ */
+/* $OpenBSD: x509.c,v 1.28 2021/12/12 20:29:15 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -1045,7 +1045,7 @@ x509_main(int argc, char **argv)
                        } else if (x509_config.modulus == i) {
                                EVP_PKEY *pkey;
 
-                               pkey = X509_get_pubkey(x);
+                               pkey = X509_get0_pubkey(x);
                                if (pkey == NULL) {
                                        BIO_printf(bio_err,
                                            "Modulus=unavailable\n");
@@ -1070,11 +1070,10 @@ x509_main(int argc, char **argv)
                                        BIO_printf(STDout,
                                            "Wrong Algorithm type");
                                BIO_printf(STDout, "\n");
-                               EVP_PKEY_free(pkey);
                        } else if (x509_config.pubkey == i) {
                                EVP_PKEY *pkey;
 
-                               pkey = X509_get_pubkey(x);
+                               pkey = X509_get0_pubkey(x);
                                if (pkey == NULL) {
                                        BIO_printf(bio_err,
                                            "Error getting public key\n");
@@ -1082,7 +1081,6 @@ x509_main(int argc, char **argv)
                                        goto end;
                                }
                                PEM_write_bio_PUBKEY(STDout, pkey);
-                               EVP_PKEY_free(pkey);
                        } else if (x509_config.C == i) {
                                unsigned char *d;
                                char *m;