Add extension free function. (Imported from upstream's 984a30423d70126ed1df30e4b52962398cdaa9b6.)
diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c index b921499..0119b45 100644 --- a/crypto/x509v3/v3_lib.c +++ b/crypto/x509v3/v3_lib.c
@@ -120,6 +120,27 @@ return X509V3_EXT_get_nid(nid); } +int X509V3_EXT_free(int nid, void *ext_data) +{ + const X509V3_EXT_METHOD *ext_method = X509V3_EXT_get_nid(nid); + if (ext_method == NULL) + { + OPENSSL_PUT_ERROR(X509V3, X509V3_EXT_free, X509V3_R_CANNOT_FIND_FREE_FUNCTION); + return 0; + } + + if (ext_method->it != NULL) + ASN1_item_free(ext_data, ASN1_ITEM_ptr(ext_method->it)); + else if (ext_method->ext_free != NULL) + ext_method->ext_free(ext_data); + else + { + OPENSSL_PUT_ERROR(X509V3, X509V3_EXT_free, X509V3_R_CANNOT_FIND_FREE_FUNCTION); + return 0; + } + + return 1; +} int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist) {
diff --git a/crypto/x509v3/x509v3.h b/crypto/x509v3/x509v3.h index 5b98441..ecddb0f 100644 --- a/crypto/x509v3/x509v3.h +++ b/crypto/x509v3/x509v3.h
@@ -783,6 +783,7 @@ #define X509V3_F_X509_PURPOSE_add 153 #define X509V3_F_SXNET_add_id_INTEGER 154 #define X509V3_F_i2v_AUTHORITY_INFO_ACCESS 155 +#define X509V3_F_X509V3_EXT_free 156 #define X509V3_R_INVALID_BOOLEAN_STRING 100 #define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 101 #define X509V3_R_INVALID_NAME 102 @@ -851,5 +852,6 @@ #define X509V3_R_DUPLICATE_ZONE_ID 165 #define X509V3_R_EXTENSION_NOT_FOUND 166 #define X509V3_R_INVALID_ASNUMBER 167 +#define X509V3_R_CANNOT_FIND_FREE_FUNCTION 168 #endif
diff --git a/crypto/x509v3/x509v3_error.c b/crypto/x509v3/x509v3_error.c index 6a8d582..e87ddfc 100644 --- a/crypto/x509v3/x509v3_error.c +++ b/crypto/x509v3/x509v3_error.c
@@ -24,6 +24,7 @@ {ERR_PACK(ERR_LIB_X509V3, X509V3_F_SXNET_get_id_ulong, 0), "SXNET_get_id_ulong"}, {ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_add, 0), "X509V3_EXT_add"}, {ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_add_alias, 0), "X509V3_EXT_add_alias"}, + {ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_free, 0), "X509V3_EXT_free"}, {ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_i2d, 0), "X509V3_EXT_i2d"}, {ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_nconf, 0), "X509V3_EXT_nconf"}, {ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_add1_i2d, 0), "X509V3_add1_i2d"}, @@ -77,6 +78,7 @@ {ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_BAD_OBJECT), "BAD_OBJECT"}, {ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_BN_DEC2BN_ERROR), "BN_DEC2BN_ERROR"}, {ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_BN_TO_ASN1_INTEGER_ERROR), "BN_TO_ASN1_INTEGER_ERROR"}, + {ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_CANNOT_FIND_FREE_FUNCTION), "CANNOT_FIND_FREE_FUNCTION"}, {ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_DIRNAME_ERROR), "DIRNAME_ERROR"}, {ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_DISTPOINT_ALREADY_SET), "DISTPOINT_ALREADY_SET"}, {ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_DUPLICATE_ZONE_ID), "DUPLICATE_ZONE_ID"},