From dd120803d2dc0eb7f78517769a955e15b3fe8d94 Mon Sep 17 00:00:00 2001 From: job Date: Thu, 2 Sep 2021 20:25:40 +0000 Subject: [PATCH] Move the error put functions from X509V3err() to X509V3error() OK tb@ --- lib/libcrypto/x509/x509_addr.c | 38 +++++++++++----------------- lib/libcrypto/x509/x509_asid.c | 46 +++++++++++++--------------------- 2 files changed, 32 insertions(+), 52 deletions(-) diff --git a/lib/libcrypto/x509/x509_addr.c b/lib/libcrypto/x509/x509_addr.c index 4e5e0b3b7ea..68145dcf5bc 100644 --- a/lib/libcrypto/x509/x509_addr.c +++ b/lib/libcrypto/x509/x509_addr.c @@ -1078,7 +1078,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, int i; if ((addr = sk_IPAddressFamily_new(IPAddressFamily_cmp)) == NULL) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); return NULL; } @@ -1100,8 +1100,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, afi = IANA_AFI_IPV6; safi = &safi_; } else { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, - X509V3_R_EXTENSION_NAME_ERROR); + X509V3error(X509V3_R_EXTENSION_NAME_ERROR); X509V3_conf_err(val); goto err; } @@ -1125,7 +1124,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, *safi = strtoul(val->value, &t, 0); t += strspn(t, " \t"); if (*safi > 0xFF || *t++ != ':') { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_SAFI); + X509V3error(X509V3_R_INVALID_SAFI); X509V3_conf_err(val); goto err; } @@ -1135,7 +1134,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, s = OPENSSL_strdup(val->value); } if (s == NULL) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto err; } @@ -1145,8 +1144,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, */ if (strcmp(s, "inherit") == 0) { if (!X509v3_addr_add_inherit(addr, afi, safi)) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, - X509V3_R_INVALID_INHERITANCE); + X509V3error(X509V3_R_INVALID_INHERITANCE); X509V3_conf_err(val); goto err; } @@ -1161,7 +1159,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, s[i1] = '\0'; if (a2i_ipadd(min, s) != length) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_IPADDRESS); + X509V3error(X509V3_R_INVALID_IPADDRESS); X509V3_conf_err(val); goto err; } @@ -1170,13 +1168,12 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, case '/': prefixlen = (int)strtoul(s + i2, &t, 10); if (t == s + i2 || *t != '\0') { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, - X509V3_R_EXTENSION_VALUE_ERROR); + X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); X509V3_conf_err(val); goto err; } if (!X509v3_addr_add_prefix(addr, afi, safi, min, prefixlen)) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto err; } break; @@ -1184,37 +1181,33 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, i1 = i2 + strspn(s + i2, " \t"); i2 = i1 + strspn(s + i1, addr_chars); if (i1 == i2 || s[i2] != '\0') { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, - X509V3_R_EXTENSION_VALUE_ERROR); + X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); X509V3_conf_err(val); goto err; } if (a2i_ipadd(max, s + i1) != length) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, - X509V3_R_INVALID_IPADDRESS); + X509V3error(X509V3_R_INVALID_IPADDRESS); X509V3_conf_err(val); goto err; } if (memcmp(min, max, length_from_afi(afi)) > 0) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, - X509V3_R_EXTENSION_VALUE_ERROR); + X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); X509V3_conf_err(val); goto err; } if (!X509v3_addr_add_range(addr, afi, safi, min, max)) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto err; } break; case '\0': if (!X509v3_addr_add_prefix(addr, afi, safi, min, length * 8)) { - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto err; } break; default: - X509V3err(X509V3_F_V2I_IPADDRBLOCKS, - X509V3_R_EXTENSION_VALUE_ERROR); + X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); X509V3_conf_err(val); goto err; } @@ -1391,8 +1384,7 @@ static int addr_validate_path_internal(X509_STORE_CTX *ctx, validation_err(X509_V_ERR_INVALID_EXTENSION); (void)sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); if ((child = sk_IPAddressFamily_dup(ext)) == NULL) { - X509V3err(X509V3_F_ADDR_VALIDATE_PATH_INTERNAL, - ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); if (ctx != NULL) ctx->error = X509_V_ERR_OUT_OF_MEM; ret = 0; diff --git a/lib/libcrypto/x509/x509_asid.c b/lib/libcrypto/x509/x509_asid.c index 59c7cabb139..1672b3c7f10 100644 --- a/lib/libcrypto/x509/x509_asid.c +++ b/lib/libcrypto/x509/x509_asid.c @@ -479,16 +479,14 @@ static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice) if ((bn == NULL && (bn = BN_new()) == NULL) || ASN1_INTEGER_to_BN(a_max, bn) == NULL || !BN_add_word(bn, 1)) { - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL, - ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto done; } if ((a_max_plus_one = BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { a_max_plus_one = orig; - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL, - ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto done; } @@ -552,8 +550,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) */ if (choice->type != ASIdentifierChoice_asIdsOrRanges || sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0) { - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, - X509V3_R_EXTENSION_VALUE_ERROR); + X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); return 0; } @@ -593,8 +590,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) * Check for overlaps. */ if (ASN1_INTEGER_cmp(a_max, b_min) >= 0) { - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, - X509V3_R_EXTENSION_VALUE_ERROR); + X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); goto done; } @@ -604,16 +600,14 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) if ((bn == NULL && (bn = BN_new()) == NULL) || ASN1_INTEGER_to_BN(a_max, bn) == NULL || !BN_add_word(bn, 1)) { - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, - ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto done; } if ((a_max_plus_one = BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { a_max_plus_one = orig; - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, - ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto done; } @@ -625,8 +619,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) switch (a->type) { case ASIdOrRange_id: if ((r = OPENSSL_malloc(sizeof(*r))) == NULL) { - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, - ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto done; } r->min = a_min; @@ -702,7 +695,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, int i; if ((asid = ASIdentifiers_new()) == NULL) { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); return NULL; } @@ -718,8 +711,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, } else if (!name_cmp(val->name, "RDI")) { which = V3_ASID_RDI; } else { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, - X509V3_R_EXTENSION_NAME_ERROR); + X509V3error(X509V3_R_EXTENSION_NAME_ERROR); X509V3_conf_err(val); goto err; } @@ -730,8 +722,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, if (strcmp(val->value, "inherit") == 0) { if (X509v3_asid_add_inherit(asid, which)) continue; - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, - X509V3_R_INVALID_INHERITANCE); + X509V3error(X509V3_R_INVALID_INHERITANCE); X509V3_conf_err(val); goto err; } @@ -746,8 +737,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, is_range = 1; i2 = i1 + strspn(val->value + i1, " \t"); if (val->value[i2] != '-') { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, - X509V3_R_INVALID_ASNUMBER); + X509V3error(X509V3_R_INVALID_ASNUMBER); X509V3_conf_err(val); goto err; } @@ -755,8 +745,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, i2 = i2 + strspn(val->value + i2, " \t"); i3 = i2 + strspn(val->value + i2, "0123456789"); if (val->value[i3] != '\0') { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, - X509V3_R_INVALID_ASRANGE); + X509V3error(X509V3_R_INVALID_ASRANGE); X509V3_conf_err(val); goto err; } @@ -767,13 +756,13 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, */ if (!is_range) { if (!X509V3_get_value_int(val, &min)) { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto err; } } else { char *s = OPENSSL_strdup(val->value); if (s == NULL) { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto err; } s[i1] = '\0'; @@ -781,17 +770,16 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, max = s2i_ASN1_INTEGER(NULL, s + i2); free(s); if (min == NULL || max == NULL) { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto err; } if (ASN1_INTEGER_cmp(min, max) > 0) { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, - X509V3_R_EXTENSION_VALUE_ERROR); + X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); goto err; } } if (!X509v3_asid_add_id_or_range(asid, which, min, max)) { - X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); + X509V3error(ERR_R_MALLOC_FAILURE); goto err; } min = max = NULL; -- 2.20.1