diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 7b5ce983a8..89feb6f106 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -39,6 +39,8 @@ #define VALIDATE_INDEX_TS_THRESH 2500 +#define MAX_DEPTH 16 ///< arbitrary limit to prevent unbounded recursion + typedef struct FLVContext { const AVClass *class; ///< Class for private options. int trust_metadata; ///< configure streams according onMetaData @@ -393,6 +395,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, char str_val[1024]; double num_val; + if (depth > MAX_DEPTH) + return AVERROR_PATCHWELCOME; + num_val = 0; ioc = s->pb; if (avio_feof(ioc))