From: Dr. Stephen Henson Date: Thu, 3 Sep 2015 13:27:19 +0000 (+0100) Subject: Limit depth of ASN1 parse printing. X-Git-Tag: OpenSSL_1_0_0t~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=275502eb41dbfc02910e48f6e55e65ea163854b9;p=oweals%2Fopenssl.git Limit depth of ASN1 parse printing. Thanks to Guido Vranken for reporting this issue. Reviewed-by: Tim Hudson (cherry picked from commit 158e5207a794603f5d64ffa95e0247c7808ab445) Conflicts: crypto/asn1/asn1_par.c --- diff --git a/crypto/asn1/asn1_par.c b/crypto/asn1/asn1_par.c index f6cd4b2b8c..4e8e25470f 100644 --- a/crypto/asn1/asn1_par.c +++ b/crypto/asn1/asn1_par.c @@ -62,6 +62,10 @@ #include #include +#ifndef ASN1_PARSE_MAXDEPTH +#define ASN1_PARSE_MAXDEPTH 128 +#endif + static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, int indent); static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, @@ -128,6 +132,12 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, #else dump_indent = 6; /* Because we know BIO_dump_indent() */ #endif + + if (depth > ASN1_PARSE_MAXDEPTH) { + BIO_puts(bp, "BAD RECURSION DEPTH\n"); + goto end; + } + p = *pp; tot = p + length; op = p - 1;