Skip to content

Commit 9790ddf

Browse files
authored
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. PR-URL: #49709 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 2bd3081 commit 9790ddf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/crypto/crypto_common.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,7 @@ static bool PrintGeneralName(const BIOPointer& out, const GENERAL_NAME* gen) {
815815
}
816816

817817
bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext) {
818-
const X509V3_EXT_METHOD* method = X509V3_EXT_get(ext);
819-
CHECK(method == X509V3_EXT_get_nid(NID_subject_alt_name));
818+
CHECK_EQ(OBJ_obj2nid(X509_EXTENSION_get_object(ext)), NID_subject_alt_name);
820819

821820
GENERAL_NAMES* names = static_cast<GENERAL_NAMES*>(X509V3_EXT_d2i(ext));
822821
if (names == nullptr)
@@ -840,8 +839,7 @@ bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext) {
840839
}
841840

842841
bool SafeX509InfoAccessPrint(const BIOPointer& out, X509_EXTENSION* ext) {
843-
const X509V3_EXT_METHOD* method = X509V3_EXT_get(ext);
844-
CHECK(method == X509V3_EXT_get_nid(NID_info_access));
842+
CHECK_EQ(OBJ_obj2nid(X509_EXTENSION_get_object(ext)), NID_info_access);
845843

846844
AUTHORITY_INFO_ACCESS* descs =
847845
static_cast<AUTHORITY_INFO_ACCESS*>(X509V3_EXT_d2i(ext));

0 commit comments

Comments
 (0)