diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_dec.c')
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_dec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index 8b02c13e6b..a6614f174e 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.54 2022/04/28 18:30:57 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_dec.c,v 1.55 2022/05/04 10:47:36 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 | */ |
@@ -92,7 +92,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, | |||
92 | static int asn1_ex_c2i(ASN1_VALUE **pval, CBS *content, int utype, | 92 | static int asn1_ex_c2i(ASN1_VALUE **pval, CBS *content, int utype, |
93 | const ASN1_ITEM *it); | 93 | const ASN1_ITEM *it); |
94 | 94 | ||
95 | static int asn1_check_tag_cbs(CBS *cbs, long *out_len, int *out_tag, | 95 | static int asn1_check_tag_cbs(CBS *cbs, size_t *out_len, int *out_tag, |
96 | uint8_t *out_class, char *out_indefinite, char *out_constructed, | 96 | uint8_t *out_class, char *out_indefinite, char *out_constructed, |
97 | int expected_tag, int expected_class, char optional); | 97 | int expected_tag, int expected_class, char optional); |
98 | static int asn1_check_tag(long *out_len, int *out_tag, uint8_t *out_class, | 98 | static int asn1_check_tag(long *out_len, int *out_tag, uint8_t *out_class, |
@@ -1048,7 +1048,7 @@ asn1_check_eoc(const unsigned char **in, long len) | |||
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | static int | 1050 | static int |
1051 | asn1_check_tag_cbs(CBS *cbs, long *out_len, int *out_tag, uint8_t *out_class, | 1051 | asn1_check_tag_cbs(CBS *cbs, size_t *out_len, int *out_tag, uint8_t *out_class, |
1052 | char *out_indefinite, char *out_constructed, int expected_tag, | 1052 | char *out_indefinite, char *out_constructed, int expected_tag, |
1053 | int expected_class, char optional) | 1053 | int expected_class, char optional) |
1054 | { | 1054 | { |
@@ -1126,6 +1126,7 @@ asn1_check_tag(long *out_len, int *out_tag, unsigned char *out_class, | |||
1126 | char *out_indefinite, char *out_constructed, const unsigned char **in, | 1126 | char *out_indefinite, char *out_constructed, const unsigned char **in, |
1127 | long len, int expected_tag, int expected_class, char optional) | 1127 | long len, int expected_tag, int expected_class, char optional) |
1128 | { | 1128 | { |
1129 | size_t length; | ||
1129 | CBS cbs; | 1130 | CBS cbs; |
1130 | int ret; | 1131 | int ret; |
1131 | 1132 | ||
@@ -1134,10 +1135,15 @@ asn1_check_tag(long *out_len, int *out_tag, unsigned char *out_class, | |||
1134 | 1135 | ||
1135 | CBS_init(&cbs, *in, len); | 1136 | CBS_init(&cbs, *in, len); |
1136 | 1137 | ||
1137 | ret = asn1_check_tag_cbs(&cbs, out_len, out_tag, out_class, | 1138 | ret = asn1_check_tag_cbs(&cbs, &length, out_tag, out_class, |
1138 | out_indefinite, out_constructed, expected_tag, expected_class, | 1139 | out_indefinite, out_constructed, expected_tag, expected_class, |
1139 | optional); | 1140 | optional); |
1140 | 1141 | ||
1142 | if (length > LONG_MAX) | ||
1143 | return 0; | ||
1144 | if (out_len != NULL) | ||
1145 | *out_len = (long)length; | ||
1146 | |||
1141 | if (ret == 1) | 1147 | if (ret == 1) |
1142 | *in = CBS_data(&cbs); | 1148 | *in = CBS_data(&cbs); |
1143 | 1149 | ||