diff options
author | job <> | 2021-09-02 20:25:40 +0000 |
---|---|---|
committer | job <> | 2021-09-02 20:25:40 +0000 |
commit | fe4f950dc448e44f66ba488d2b4d5ed042fc6ad2 (patch) | |
tree | 167a35aa653380f06ff5d44dcf68512f45b2c446 /src/lib | |
parent | 42689e06782909a72cd58175622d83edd974719a (diff) | |
download | openbsd-fe4f950dc448e44f66ba488d2b4d5ed042fc6ad2.tar.gz openbsd-fe4f950dc448e44f66ba488d2b4d5ed042fc6ad2.tar.bz2 openbsd-fe4f950dc448e44f66ba488d2b4d5ed042fc6ad2.zip |
Move the error put functions from X509V3err() to X509V3error()
OK tb@
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/x509/x509_addr.c | 38 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_asid.c | 46 |
2 files changed, 32 insertions, 52 deletions
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c index 4e5e0b3b7e..68145dcf5b 100644 --- a/src/lib/libcrypto/x509/x509_addr.c +++ b/src/lib/libcrypto/x509/x509_addr.c | |||
@@ -1078,7 +1078,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | |||
1078 | int i; | 1078 | int i; |
1079 | 1079 | ||
1080 | if ((addr = sk_IPAddressFamily_new(IPAddressFamily_cmp)) == NULL) { | 1080 | if ((addr = sk_IPAddressFamily_new(IPAddressFamily_cmp)) == NULL) { |
1081 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); | 1081 | X509V3error(ERR_R_MALLOC_FAILURE); |
1082 | return NULL; | 1082 | return NULL; |
1083 | } | 1083 | } |
1084 | 1084 | ||
@@ -1100,8 +1100,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | |||
1100 | afi = IANA_AFI_IPV6; | 1100 | afi = IANA_AFI_IPV6; |
1101 | safi = &safi_; | 1101 | safi = &safi_; |
1102 | } else { | 1102 | } else { |
1103 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, | 1103 | X509V3error(X509V3_R_EXTENSION_NAME_ERROR); |
1104 | X509V3_R_EXTENSION_NAME_ERROR); | ||
1105 | X509V3_conf_err(val); | 1104 | X509V3_conf_err(val); |
1106 | goto err; | 1105 | goto err; |
1107 | } | 1106 | } |
@@ -1125,7 +1124,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | |||
1125 | *safi = strtoul(val->value, &t, 0); | 1124 | *safi = strtoul(val->value, &t, 0); |
1126 | t += strspn(t, " \t"); | 1125 | t += strspn(t, " \t"); |
1127 | if (*safi > 0xFF || *t++ != ':') { | 1126 | if (*safi > 0xFF || *t++ != ':') { |
1128 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_SAFI); | 1127 | X509V3error(X509V3_R_INVALID_SAFI); |
1129 | X509V3_conf_err(val); | 1128 | X509V3_conf_err(val); |
1130 | goto err; | 1129 | goto err; |
1131 | } | 1130 | } |
@@ -1135,7 +1134,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | |||
1135 | s = OPENSSL_strdup(val->value); | 1134 | s = OPENSSL_strdup(val->value); |
1136 | } | 1135 | } |
1137 | if (s == NULL) { | 1136 | if (s == NULL) { |
1138 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); | 1137 | X509V3error(ERR_R_MALLOC_FAILURE); |
1139 | goto err; | 1138 | goto err; |
1140 | } | 1139 | } |
1141 | 1140 | ||
@@ -1145,8 +1144,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | |||
1145 | */ | 1144 | */ |
1146 | if (strcmp(s, "inherit") == 0) { | 1145 | if (strcmp(s, "inherit") == 0) { |
1147 | if (!X509v3_addr_add_inherit(addr, afi, safi)) { | 1146 | if (!X509v3_addr_add_inherit(addr, afi, safi)) { |
1148 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, | 1147 | X509V3error(X509V3_R_INVALID_INHERITANCE); |
1149 | X509V3_R_INVALID_INHERITANCE); | ||
1150 | X509V3_conf_err(val); | 1148 | X509V3_conf_err(val); |
1151 | goto err; | 1149 | goto err; |
1152 | } | 1150 | } |
@@ -1161,7 +1159,7 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | |||
1161 | s[i1] = '\0'; | 1159 | s[i1] = '\0'; |
1162 | 1160 | ||
1163 | if (a2i_ipadd(min, s) != length) { | 1161 | if (a2i_ipadd(min, s) != length) { |
1164 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_IPADDRESS); | 1162 | X509V3error(X509V3_R_INVALID_IPADDRESS); |
1165 | X509V3_conf_err(val); | 1163 | X509V3_conf_err(val); |
1166 | goto err; | 1164 | goto err; |
1167 | } | 1165 | } |
@@ -1170,13 +1168,12 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | |||
1170 | case '/': | 1168 | case '/': |
1171 | prefixlen = (int)strtoul(s + i2, &t, 10); | 1169 | prefixlen = (int)strtoul(s + i2, &t, 10); |
1172 | if (t == s + i2 || *t != '\0') { | 1170 | if (t == s + i2 || *t != '\0') { |
1173 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, | 1171 | X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); |
1174 | X509V3_R_EXTENSION_VALUE_ERROR); | ||
1175 | X509V3_conf_err(val); | 1172 | X509V3_conf_err(val); |
1176 | goto err; | 1173 | goto err; |
1177 | } | 1174 | } |
1178 | if (!X509v3_addr_add_prefix(addr, afi, safi, min, prefixlen)) { | 1175 | if (!X509v3_addr_add_prefix(addr, afi, safi, min, prefixlen)) { |
1179 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); | 1176 | X509V3error(ERR_R_MALLOC_FAILURE); |
1180 | goto err; | 1177 | goto err; |
1181 | } | 1178 | } |
1182 | break; | 1179 | break; |
@@ -1184,37 +1181,33 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, | |||
1184 | i1 = i2 + strspn(s + i2, " \t"); | 1181 | i1 = i2 + strspn(s + i2, " \t"); |
1185 | i2 = i1 + strspn(s + i1, addr_chars); | 1182 | i2 = i1 + strspn(s + i1, addr_chars); |
1186 | if (i1 == i2 || s[i2] != '\0') { | 1183 | if (i1 == i2 || s[i2] != '\0') { |
1187 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, | 1184 | X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); |
1188 | X509V3_R_EXTENSION_VALUE_ERROR); | ||
1189 | X509V3_conf_err(val); | 1185 | X509V3_conf_err(val); |
1190 | goto err; | 1186 | goto err; |
1191 | } | 1187 | } |
1192 | if (a2i_ipadd(max, s + i1) != length) { | 1188 | if (a2i_ipadd(max, s + i1) != length) { |
1193 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, | 1189 | X509V3error(X509V3_R_INVALID_IPADDRESS); |
1194 | X509V3_R_INVALID_IPADDRESS); | ||
1195 | X509V3_conf_err(val); | 1190 | X509V3_conf_err(val); |
1196 | goto err; | 1191 | goto err; |
1197 | } | 1192 | } |
1198 | if (memcmp(min, max, length_from_afi(afi)) > 0) { | 1193 | if (memcmp(min, max, length_from_afi(afi)) > 0) { |
1199 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, | 1194 | X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); |
1200 | X509V3_R_EXTENSION_VALUE_ERROR); | ||
1201 | X509V3_conf_err(val); | 1195 | X509V3_conf_err(val); |
1202 | goto err; | 1196 | goto err; |
1203 | } | 1197 | } |
1204 | if (!X509v3_addr_add_range(addr, afi, safi, min, max)) { | 1198 | if (!X509v3_addr_add_range(addr, afi, safi, min, max)) { |
1205 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); | 1199 | X509V3error(ERR_R_MALLOC_FAILURE); |
1206 | goto err; | 1200 | goto err; |
1207 | } | 1201 | } |
1208 | break; | 1202 | break; |
1209 | case '\0': | 1203 | case '\0': |
1210 | if (!X509v3_addr_add_prefix(addr, afi, safi, min, length * 8)) { | 1204 | if (!X509v3_addr_add_prefix(addr, afi, safi, min, length * 8)) { |
1211 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE); | 1205 | X509V3error(ERR_R_MALLOC_FAILURE); |
1212 | goto err; | 1206 | goto err; |
1213 | } | 1207 | } |
1214 | break; | 1208 | break; |
1215 | default: | 1209 | default: |
1216 | X509V3err(X509V3_F_V2I_IPADDRBLOCKS, | 1210 | X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); |
1217 | X509V3_R_EXTENSION_VALUE_ERROR); | ||
1218 | X509V3_conf_err(val); | 1211 | X509V3_conf_err(val); |
1219 | goto err; | 1212 | goto err; |
1220 | } | 1213 | } |
@@ -1391,8 +1384,7 @@ static int addr_validate_path_internal(X509_STORE_CTX *ctx, | |||
1391 | validation_err(X509_V_ERR_INVALID_EXTENSION); | 1384 | validation_err(X509_V_ERR_INVALID_EXTENSION); |
1392 | (void)sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); | 1385 | (void)sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp); |
1393 | if ((child = sk_IPAddressFamily_dup(ext)) == NULL) { | 1386 | if ((child = sk_IPAddressFamily_dup(ext)) == NULL) { |
1394 | X509V3err(X509V3_F_ADDR_VALIDATE_PATH_INTERNAL, | 1387 | X509V3error(ERR_R_MALLOC_FAILURE); |
1395 | ERR_R_MALLOC_FAILURE); | ||
1396 | if (ctx != NULL) | 1388 | if (ctx != NULL) |
1397 | ctx->error = X509_V_ERR_OUT_OF_MEM; | 1389 | ctx->error = X509_V_ERR_OUT_OF_MEM; |
1398 | ret = 0; | 1390 | ret = 0; |
diff --git a/src/lib/libcrypto/x509/x509_asid.c b/src/lib/libcrypto/x509/x509_asid.c index 59c7cabb13..1672b3c7f1 100644 --- a/src/lib/libcrypto/x509/x509_asid.c +++ b/src/lib/libcrypto/x509/x509_asid.c | |||
@@ -479,16 +479,14 @@ static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice) | |||
479 | if ((bn == NULL && (bn = BN_new()) == NULL) || | 479 | if ((bn == NULL && (bn = BN_new()) == NULL) || |
480 | ASN1_INTEGER_to_BN(a_max, bn) == NULL || | 480 | ASN1_INTEGER_to_BN(a_max, bn) == NULL || |
481 | !BN_add_word(bn, 1)) { | 481 | !BN_add_word(bn, 1)) { |
482 | X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL, | 482 | X509V3error(ERR_R_MALLOC_FAILURE); |
483 | ERR_R_MALLOC_FAILURE); | ||
484 | goto done; | 483 | goto done; |
485 | } | 484 | } |
486 | 485 | ||
487 | if ((a_max_plus_one = | 486 | if ((a_max_plus_one = |
488 | BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { | 487 | BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { |
489 | a_max_plus_one = orig; | 488 | a_max_plus_one = orig; |
490 | X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL, | 489 | X509V3error(ERR_R_MALLOC_FAILURE); |
491 | ERR_R_MALLOC_FAILURE); | ||
492 | goto done; | 490 | goto done; |
493 | } | 491 | } |
494 | 492 | ||
@@ -552,8 +550,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) | |||
552 | */ | 550 | */ |
553 | if (choice->type != ASIdentifierChoice_asIdsOrRanges || | 551 | if (choice->type != ASIdentifierChoice_asIdsOrRanges || |
554 | sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0) { | 552 | sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0) { |
555 | X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, | 553 | X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); |
556 | X509V3_R_EXTENSION_VALUE_ERROR); | ||
557 | return 0; | 554 | return 0; |
558 | } | 555 | } |
559 | 556 | ||
@@ -593,8 +590,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) | |||
593 | * Check for overlaps. | 590 | * Check for overlaps. |
594 | */ | 591 | */ |
595 | if (ASN1_INTEGER_cmp(a_max, b_min) >= 0) { | 592 | if (ASN1_INTEGER_cmp(a_max, b_min) >= 0) { |
596 | X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, | 593 | X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); |
597 | X509V3_R_EXTENSION_VALUE_ERROR); | ||
598 | goto done; | 594 | goto done; |
599 | } | 595 | } |
600 | 596 | ||
@@ -604,16 +600,14 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) | |||
604 | if ((bn == NULL && (bn = BN_new()) == NULL) || | 600 | if ((bn == NULL && (bn = BN_new()) == NULL) || |
605 | ASN1_INTEGER_to_BN(a_max, bn) == NULL || | 601 | ASN1_INTEGER_to_BN(a_max, bn) == NULL || |
606 | !BN_add_word(bn, 1)) { | 602 | !BN_add_word(bn, 1)) { |
607 | X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, | 603 | X509V3error(ERR_R_MALLOC_FAILURE); |
608 | ERR_R_MALLOC_FAILURE); | ||
609 | goto done; | 604 | goto done; |
610 | } | 605 | } |
611 | 606 | ||
612 | if ((a_max_plus_one = | 607 | if ((a_max_plus_one = |
613 | BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { | 608 | BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { |
614 | a_max_plus_one = orig; | 609 | a_max_plus_one = orig; |
615 | X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, | 610 | X509V3error(ERR_R_MALLOC_FAILURE); |
616 | ERR_R_MALLOC_FAILURE); | ||
617 | goto done; | 611 | goto done; |
618 | } | 612 | } |
619 | 613 | ||
@@ -625,8 +619,7 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) | |||
625 | switch (a->type) { | 619 | switch (a->type) { |
626 | case ASIdOrRange_id: | 620 | case ASIdOrRange_id: |
627 | if ((r = OPENSSL_malloc(sizeof(*r))) == NULL) { | 621 | if ((r = OPENSSL_malloc(sizeof(*r))) == NULL) { |
628 | X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, | 622 | X509V3error(ERR_R_MALLOC_FAILURE); |
629 | ERR_R_MALLOC_FAILURE); | ||
630 | goto done; | 623 | goto done; |
631 | } | 624 | } |
632 | r->min = a_min; | 625 | r->min = a_min; |
@@ -702,7 +695,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, | |||
702 | int i; | 695 | int i; |
703 | 696 | ||
704 | if ((asid = ASIdentifiers_new()) == NULL) { | 697 | if ((asid = ASIdentifiers_new()) == NULL) { |
705 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); | 698 | X509V3error(ERR_R_MALLOC_FAILURE); |
706 | return NULL; | 699 | return NULL; |
707 | } | 700 | } |
708 | 701 | ||
@@ -718,8 +711,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, | |||
718 | } else if (!name_cmp(val->name, "RDI")) { | 711 | } else if (!name_cmp(val->name, "RDI")) { |
719 | which = V3_ASID_RDI; | 712 | which = V3_ASID_RDI; |
720 | } else { | 713 | } else { |
721 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, | 714 | X509V3error(X509V3_R_EXTENSION_NAME_ERROR); |
722 | X509V3_R_EXTENSION_NAME_ERROR); | ||
723 | X509V3_conf_err(val); | 715 | X509V3_conf_err(val); |
724 | goto err; | 716 | goto err; |
725 | } | 717 | } |
@@ -730,8 +722,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, | |||
730 | if (strcmp(val->value, "inherit") == 0) { | 722 | if (strcmp(val->value, "inherit") == 0) { |
731 | if (X509v3_asid_add_inherit(asid, which)) | 723 | if (X509v3_asid_add_inherit(asid, which)) |
732 | continue; | 724 | continue; |
733 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, | 725 | X509V3error(X509V3_R_INVALID_INHERITANCE); |
734 | X509V3_R_INVALID_INHERITANCE); | ||
735 | X509V3_conf_err(val); | 726 | X509V3_conf_err(val); |
736 | goto err; | 727 | goto err; |
737 | } | 728 | } |
@@ -746,8 +737,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, | |||
746 | is_range = 1; | 737 | is_range = 1; |
747 | i2 = i1 + strspn(val->value + i1, " \t"); | 738 | i2 = i1 + strspn(val->value + i1, " \t"); |
748 | if (val->value[i2] != '-') { | 739 | if (val->value[i2] != '-') { |
749 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, | 740 | X509V3error(X509V3_R_INVALID_ASNUMBER); |
750 | X509V3_R_INVALID_ASNUMBER); | ||
751 | X509V3_conf_err(val); | 741 | X509V3_conf_err(val); |
752 | goto err; | 742 | goto err; |
753 | } | 743 | } |
@@ -755,8 +745,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, | |||
755 | i2 = i2 + strspn(val->value + i2, " \t"); | 745 | i2 = i2 + strspn(val->value + i2, " \t"); |
756 | i3 = i2 + strspn(val->value + i2, "0123456789"); | 746 | i3 = i2 + strspn(val->value + i2, "0123456789"); |
757 | if (val->value[i3] != '\0') { | 747 | if (val->value[i3] != '\0') { |
758 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, | 748 | X509V3error(X509V3_R_INVALID_ASRANGE); |
759 | X509V3_R_INVALID_ASRANGE); | ||
760 | X509V3_conf_err(val); | 749 | X509V3_conf_err(val); |
761 | goto err; | 750 | goto err; |
762 | } | 751 | } |
@@ -767,13 +756,13 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, | |||
767 | */ | 756 | */ |
768 | if (!is_range) { | 757 | if (!is_range) { |
769 | if (!X509V3_get_value_int(val, &min)) { | 758 | if (!X509V3_get_value_int(val, &min)) { |
770 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); | 759 | X509V3error(ERR_R_MALLOC_FAILURE); |
771 | goto err; | 760 | goto err; |
772 | } | 761 | } |
773 | } else { | 762 | } else { |
774 | char *s = OPENSSL_strdup(val->value); | 763 | char *s = OPENSSL_strdup(val->value); |
775 | if (s == NULL) { | 764 | if (s == NULL) { |
776 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); | 765 | X509V3error(ERR_R_MALLOC_FAILURE); |
777 | goto err; | 766 | goto err; |
778 | } | 767 | } |
779 | s[i1] = '\0'; | 768 | s[i1] = '\0'; |
@@ -781,17 +770,16 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method, | |||
781 | max = s2i_ASN1_INTEGER(NULL, s + i2); | 770 | max = s2i_ASN1_INTEGER(NULL, s + i2); |
782 | free(s); | 771 | free(s); |
783 | if (min == NULL || max == NULL) { | 772 | if (min == NULL || max == NULL) { |
784 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); | 773 | X509V3error(ERR_R_MALLOC_FAILURE); |
785 | goto err; | 774 | goto err; |
786 | } | 775 | } |
787 | if (ASN1_INTEGER_cmp(min, max) > 0) { | 776 | if (ASN1_INTEGER_cmp(min, max) > 0) { |
788 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, | 777 | X509V3error(X509V3_R_EXTENSION_VALUE_ERROR); |
789 | X509V3_R_EXTENSION_VALUE_ERROR); | ||
790 | goto err; | 778 | goto err; |
791 | } | 779 | } |
792 | } | 780 | } |
793 | if (!X509v3_asid_add_id_or_range(asid, which, min, max)) { | 781 | if (!X509v3_asid_add_id_or_range(asid, which, min, max)) { |
794 | X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE); | 782 | X509V3error(ERR_R_MALLOC_FAILURE); |
795 | goto err; | 783 | goto err; |
796 | } | 784 | } |
797 | min = max = NULL; | 785 | min = max = NULL; |