From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A266C40F12 for ; Sat, 1 Jan 2022 19:20:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1629A68B13E; Sat, 1 Jan 2022 21:20:19 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A8E9E68B13C for ; Sat, 1 Jan 2022 21:20:12 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 42D3EE65E2; Sat, 1 Jan 2022 20:20:12 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9ZaF3yKFziCq; Sat, 1 Jan 2022 20:20:11 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D546CE64BA; Sat, 1 Jan 2022 20:20:10 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Jan 2022 20:20:01 +0100 Message-Id: <20220101192001.13688-2-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220101192001.13688-1-cus@passwd.hu> References: <20220101192001.13688-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/dashdec: do not use filesize when reading XML file 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: Marton Balint 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: Signed-off-by: Marton Balint --- libavformat/dashdec.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 797fe74157..0d21989e42 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -30,8 +30,6 @@ #include "dash.h" #define INITIAL_BUFFER_SIZE 32768 -#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) -#define DEFAULT_MANIFEST_SIZE 8 * 1024 struct fragment { int64_t url_offset; @@ -1195,7 +1193,6 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) DASHContext *c = s->priv_data; int ret = 0; int close_in = 0; - int64_t filesize = 0; AVBPrint buf; AVDictionary *opts = NULL; xmlDoc *doc = NULL; @@ -1226,26 +1223,17 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, (uint8_t**)&c->base_url) < 0) c->base_url = av_strdup(url); - filesize = avio_size(in); - filesize = filesize > 0 ? filesize : DEFAULT_MANIFEST_SIZE; + av_bprint_init(&buf, 0, INT_MAX); // xmlReadMemory uses integer bufsize - if (filesize > MAX_BPRINT_READ_SIZE) { - av_log(s, AV_LOG_ERROR, "Manifest too large: %"PRId64"\n", filesize); - return AVERROR_INVALIDDATA; - } - - av_bprint_init(&buf, filesize + 1, AV_BPRINT_SIZE_UNLIMITED); - - if ((ret = avio_read_to_bprint(in, &buf, MAX_BPRINT_READ_SIZE)) < 0 || - !avio_feof(in) || - (filesize = buf.len) == 0) { + if ((ret = avio_read_to_bprint(in, &buf, SIZE_MAX)) < 0 || + !avio_feof(in)) { av_log(s, AV_LOG_ERROR, "Unable to read to manifest '%s'\n", url); if (ret == 0) ret = AVERROR_INVALIDDATA; } else { LIBXML_TEST_VERSION - doc = xmlReadMemory(buf.str, filesize, c->base_url, NULL, 0); + doc = xmlReadMemory(buf.str, buf.len, c->base_url, NULL, 0); root_element = xmlDocGetRootElement(doc); node = root_element; -- 2.31.1 _______________________________________________ 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".