From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 0AB3E5001A for ; Mon, 7 Jul 2025 10:31:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 345036914F7; Mon, 7 Jul 2025 13:31:13 +0300 (EEST) Received: from relay15.mail.gandi.net (relay15.mail.gandi.net [217.70.178.235]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 2DA3E68FE47 for ; Mon, 7 Jul 2025 13:31:06 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 60D9443192; Mon, 7 Jul 2025 10:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1751884265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cDJJF4B5XXI962MeQdCzrZ3WFD4h7W8QQVxJ2icxHco=; b=RwgBHOTMM0SlC1jnhVubz7bQDfAJDpx0yBqhILaMmpXV3L8Ysl6ZOKepi71KIbQx4ublYS lgUGSzy+6InQAEayfI8rlr5NkoCirR/1uBzKtqpkfg8dDLTbTEV+h2zpNaLeaRl3dhRKjS hP1QN24lclHbu3pdkQSvIh3RyZcXS4PuSX7adC2VaZGT/04fRCkjSGe9SnNRasnDUOLd0L qLl1f3XbMlx2orzuH2idQx2SEAM0HVqSYU3hou2r4QBqkrbVNN44G4QvSiDRX2lbUz2H1T nVoVJ3pF/e7QAqVFEFsGO48VLXrhJqv2rf4sLaduOLSw7HVv7yiKxJi048Yf6Q== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 7 Jul 2025 12:31:02 +0200 Message-ID: <20250707103102.3477457-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250707103102.3477457-1-michael@niedermayer.cc> References: <20250707103102.3477457-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -70 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdefudehiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdlfedtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpeeljeeugeeiiedtjeduudfhgeefudevtdehudduvefftdeileejhfelvdelteehgeenucfkphepgedurdeiiedrieeirddvvdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieeirddvvdejpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepvddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhgpdhrtghpthhtohepuggrnhhishhjihgrnhhgsehgmhgrihhlrdgtohhm Subject: [FFmpeg-devel] [PATCH 2/2] avformat/concatdec: Check recursion depth X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Yuhao Jiang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This variant is easy backportable but is concatdec specific Fixes: self_ref.ffconcat Reported-by: Yuhao Jiang Signed-off-by: Michael Niedermayer --- libavformat/concatdec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index fe65d0c7688..66b8f417983 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -72,6 +72,7 @@ typedef struct { ConcatMatchMode stream_match_mode; unsigned auto_convert; int segment_time_metadata; + int recursion_depth; } ConcatContext; static int concat_probe(const AVProbeData *probe) @@ -356,6 +357,8 @@ static int open_file(AVFormatContext *avf, unsigned fileno) if (ret < 0) return ret; + av_dict_set_int(&options, "recursion_depth", cat->recursion_depth - 1, 0); + if ((ret = avformat_open_input(&cat->avf, file->url, NULL, &options)) < 0 || (ret = avformat_find_stream_info(cat->avf, NULL)) < 0) { av_log(avf, AV_LOG_ERROR, "Impossible to open '%s'\n", file->url); @@ -363,6 +366,7 @@ static int open_file(AVFormatContext *avf, unsigned fileno) avformat_close_input(&cat->avf); return ret; } + av_dict_set(&options, "recursion_depth", NULL, 0); if (options) { av_log(avf, AV_LOG_WARNING, "Unused options for '%s'.\n", file->url); /* TODO log unused options once we have a proper string API */ @@ -664,6 +668,11 @@ static int concat_read_header(AVFormatContext *avf) unsigned i; int ret; + if (cat->recursion_depth <= 0) { + av_log(avf, AV_LOG_ERROR, "Too deep recursion\n"); + return AVERROR(ELOOP); + } + ret = concat_parse_script(avf); if (ret < 0) return ret; @@ -939,6 +948,8 @@ static const AVOption options[] = { OFFSET(auto_convert), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC }, { "segment_time_metadata", "output file segment start time and duration as packet metadata", OFFSET(segment_time_metadata), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC }, + { "recursion_depth", "max recursion depth", + OFFSET(recursion_depth), AV_OPT_TYPE_INT, {.i64 = 10}, 0, INT_MAX, DEC }, { NULL } }; -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".