From 48ba7b2cc0bc161bec9c96390a11c8ed811f995b Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 18 Sep 2023 13:19:11 -0400 Subject: [PATCH] crypto: simplify assertions in Safe*Print Checking the X509V3_EXT_METHOD doesn't do anything. X509V3_EXT_get is already implemented by calling X509V3_EXT_get_nid on the extension's NID. We may as well just check the NID directly. --- src/crypto/crypto_common.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc index c6120a655ec853..3517c39ad0b71a 100644 --- a/src/crypto/crypto_common.cc +++ b/src/crypto/crypto_common.cc @@ -815,8 +815,7 @@ static bool PrintGeneralName(const BIOPointer& out, const GENERAL_NAME* gen) { } bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext) { - const X509V3_EXT_METHOD* method = X509V3_EXT_get(ext); - CHECK(method == X509V3_EXT_get_nid(NID_subject_alt_name)); + CHECK_EQ(OBJ_obj2nid(X509_EXTENSION_get_object(ext)), NID_subject_alt_name); GENERAL_NAMES* names = static_cast(X509V3_EXT_d2i(ext)); if (names == nullptr) @@ -840,8 +839,7 @@ bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext) { } bool SafeX509InfoAccessPrint(const BIOPointer& out, X509_EXTENSION* ext) { - const X509V3_EXT_METHOD* method = X509V3_EXT_get(ext); - CHECK(method == X509V3_EXT_get_nid(NID_info_access)); + CHECK_EQ(OBJ_obj2nid(X509_EXTENSION_get_object(ext)), NID_info_access); AUTHORITY_INFO_ACCESS* descs = static_cast(X509V3_EXT_d2i(ext));