summaryrefslogtreecommitdiff
path: root/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c')
-rw-r--r--libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c b/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c
index 142ef95..cb93e8f 100644
--- a/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c
+++ b/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c
@@ -79,8 +79,8 @@ static int _new_element(ltc_asn1_list **l)
*/
int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out)
{
- ltc_asn1_list *l;
- unsigned long err, type, len, totlen, data_offset;
+ ltc_asn1_list *l, *t;
+ unsigned long err, type, len, totlen, data_offset, len_len;
void *realloc_tmp;
LTC_ARGCHK(in != NULL);
@@ -407,6 +407,17 @@ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc
l->child->parent = l;
}
+ t = l;
+ len_len = 0;
+ while((t != NULL) && (t->child != NULL)) {
+ len_len++;
+ t = t->child;
+ }
+ if (len_len > LTC_DER_MAX_RECURSION) {
+ err = CRYPT_ERROR;
+ goto error;
+ }
+
break;
case 0x80: /* Context-specific */