diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/tasn_dec.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index a769ace975..03a4d6313b 100644 --- a/src/lib/libcrypto/asn1/tasn_dec.c +++ b/src/lib/libcrypto/asn1/tasn_dec.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tasn_dec.c,v 1.74 2022/05/21 11:21:31 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_dec.c,v 1.75 2022/05/21 13:16:19 jsing Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -903,6 +903,35 @@ asn1_item_d2i_sequence(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
| 903 | return 0; | 903 | return 0; |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | static int | ||
| 907 | asn1_item_d2i_extern(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | ||
| 908 | int tag_number, int tag_class, char optional) | ||
| 909 | { | ||
| 910 | const ASN1_EXTERN_FUNCS *ef = it->funcs; | ||
| 911 | const unsigned char *p = NULL; | ||
| 912 | ASN1_TLC ctx = { 0 }; | ||
| 913 | int ret = 0; | ||
| 914 | |||
| 915 | if (CBS_len(cbs) > LONG_MAX) | ||
| 916 | return 0; | ||
| 917 | |||
| 918 | p = CBS_data(cbs); | ||
| 919 | |||
| 920 | if ((ret = ef->asn1_ex_d2i(pval, &p, (long)CBS_len(cbs), it, | ||
| 921 | tag_number, tag_class, optional, &ctx)) == 1) { | ||
| 922 | if (!CBS_skip(cbs, p - CBS_data(cbs))) | ||
| 923 | goto err; | ||
| 924 | } | ||
| 925 | return ret; | ||
| 926 | |||
| 927 | err: | ||
| 928 | ASN1_item_ex_free(pval, it); | ||
| 929 | |||
| 930 | ERR_asprintf_error_data("Type=%s", it->sname); | ||
| 931 | |||
| 932 | return 0; | ||
| 933 | } | ||
| 934 | |||
| 906 | /* | 935 | /* |
| 907 | * Decode an item, taking care of IMPLICIT tagging, if any. | 936 | * Decode an item, taking care of IMPLICIT tagging, if any. |
| 908 | * If 'opt' set and tag mismatch return -1 to handle OPTIONAL | 937 | * If 'opt' set and tag mismatch return -1 to handle OPTIONAL |
| @@ -911,11 +940,6 @@ static int | |||
| 911 | asn1_item_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | 940 | asn1_item_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, |
| 912 | int tag_number, int tag_class, char optional, int depth) | 941 | int tag_number, int tag_class, char optional, int depth) |
| 913 | { | 942 | { |
| 914 | const ASN1_EXTERN_FUNCS *ef = it->funcs; | ||
| 915 | const unsigned char *p = NULL; | ||
| 916 | ASN1_TLC ctx = { 0 }; | ||
| 917 | int ret = 0; | ||
| 918 | |||
| 919 | if (pval == NULL) | 943 | if (pval == NULL) |
| 920 | return 0; | 944 | return 0; |
| 921 | 945 | ||
| @@ -949,15 +973,8 @@ asn1_item_d2i(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
| 949 | optional); | 973 | optional); |
| 950 | 974 | ||
| 951 | case ASN1_ITYPE_EXTERN: | 975 | case ASN1_ITYPE_EXTERN: |
| 952 | if (CBS_len(cbs) > LONG_MAX) | 976 | return asn1_item_d2i_extern(pval, cbs, it, tag_number, |
| 953 | return 0; | 977 | tag_class, optional); |
| 954 | p = CBS_data(cbs); | ||
| 955 | if ((ret = ef->asn1_ex_d2i(pval, &p, (long)CBS_len(cbs), it, | ||
| 956 | tag_number, tag_class, optional, &ctx)) == 1) { | ||
| 957 | if (!CBS_skip(cbs, p - CBS_data(cbs))) | ||
| 958 | goto err; | ||
| 959 | } | ||
| 960 | return ret; | ||
| 961 | 978 | ||
| 962 | case ASN1_ITYPE_CHOICE: | 979 | case ASN1_ITYPE_CHOICE: |
| 963 | return asn1_item_d2i_choice(pval, cbs, it, tag_number, | 980 | return asn1_item_d2i_choice(pval, cbs, it, tag_number, |
