From a4847c4619a20761856a1bb304cbc7affeecdb15 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Sat, 20 Apr 2024 08:56:01 -0400 Subject: [PATCH] crypto: simplify assertions in Safe*Print MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. PR-URL: https://github.com/nodejs/node/pull/49709 Reviewed-By: Tobias Nießen Reviewed-By: Richard Lau --- 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));