diff options
author | jsing <> | 2021-12-09 16:58:44 +0000 |
---|---|---|
committer | jsing <> | 2021-12-09 16:58:44 +0000 |
commit | b7e6ffcafce5f9b56e53dc811cb7a058d61229e3 (patch) | |
tree | 143559c62c1aa4a07e8fa25ad18a82a6e9ac09c1 /src | |
parent | 6e8a5f666a6873d46f12bf3f99a69cfeac3cdc3f (diff) | |
download | openbsd-b7e6ffcafce5f9b56e53dc811cb7a058d61229e3.tar.gz openbsd-b7e6ffcafce5f9b56e53dc811cb7a058d61229e3.tar.bz2 openbsd-b7e6ffcafce5f9b56e53dc811cb7a058d61229e3.zip |
Pull the recursion depth check up to the top of asn1_collect()
ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_dec.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index b1fb5886c4..aa97bc8f4e 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.42 2021/12/09 16:56:15 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_dec.c,v 1.43 2021/12/09 16:58:44 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 | */ |
@@ -1020,6 +1020,11 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, | |||
1020 | long plen; | 1020 | long plen; |
1021 | char cst, ininf; | 1021 | char cst, ininf; |
1022 | 1022 | ||
1023 | if (depth > ASN1_MAX_STRING_NEST) { | ||
1024 | ASN1error(ASN1_R_NESTED_ASN1_STRING); | ||
1025 | return 0; | ||
1026 | } | ||
1027 | |||
1023 | p = *in; | 1028 | p = *in; |
1024 | inf &= 1; | 1029 | inf &= 1; |
1025 | 1030 | ||
@@ -1045,10 +1050,6 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, | |||
1045 | 1050 | ||
1046 | /* If indefinite length constructed update max length */ | 1051 | /* If indefinite length constructed update max length */ |
1047 | if (cst) { | 1052 | if (cst) { |
1048 | if (depth >= ASN1_MAX_STRING_NEST) { | ||
1049 | ASN1error(ASN1_R_NESTED_ASN1_STRING); | ||
1050 | return 0; | ||
1051 | } | ||
1052 | if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, | 1053 | if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, |
1053 | depth + 1)) | 1054 | depth + 1)) |
1054 | return 0; | 1055 | return 0; |