From patchwork Sat Jan 1 19:20:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 32997 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp14945376iog; Sat, 1 Jan 2022 11:20:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkz/bsjk8yudKqJIft2TVzdMfCg9UARQVJVlxZ6PB4QZZ81e6ooEnjEffIZJk8UelmO77i X-Received: by 2002:a17:907:6287:: with SMTP id nd7mr31026035ejc.152.1641064821186; Sat, 01 Jan 2022 11:20:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641064821; cv=none; d=google.com; s=arc-20160816; b=vlGqsyKU2c6FqPnlA6QOe01qVSyHMboYXu3qisLsY0L51D4bQQvjpZcEN4r5genYO1 71nOOicxiyOg2+MKrbAgXw5tWh+4jrQd0qFiMIJmYoEyXiVbQmZfvop5GvipWgtZyK07 t9QZWi0ZdhP6d4JcLqzru4KATTiZbBJgcaPz5DZs4dHbAwtv2AAtoiJbceWs62Hh/jK2 EXzJAvEdwvge/NCzGC19UC3El6+Cj7Fp9x5lIt4lJymjXEijsdNZimTc/+vkp0N1oLtI 6Sgz2kn9Kqzhv0Wtg+jcwAF6M61tY7WnD6f5Jfxwv4UyRGU3fki47rSMZcKrOeOB0nIR Vm6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=IKOx/kq5HnQSseZpEJbITHvfmvdfoxXqnCzbSz14G7A=; b=MumaiD69ue9akGfGsMMmEfGz4JK/dS2oBIi4qAC3DAPhn01mayN52z41x+4SoTwZbn C+VBFCF7vRlJ4rRlwQFxyQfH2JR3Wr3sKIEh4g9x4iCa1OezFLJwckIh5Jqe8SFxQNLE 6tsBnhnuMO847cNWJGqibEXWmdnEWO3qCC5wm5+ee1aKX/VNUk4botkqkYoEzkcgK0NO VbfFBziR1Ym12ZJm3OIHqSKRzQvuJg9Au/AUvP3aiyJcJlcsRms2uO6w1GLrropDmTkt vrmRKqfvduG5+QtyeZsJRnciEol3b9o6neHTCjKtxfiRwsNXqhWfl4/uc1hT9NLHBlOP dT/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k16si611332ejj.429.2022.01.01.11.20.20; Sat, 01 Jan 2022 11:20:21 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 39C5868B133; Sat, 1 Jan 2022 21:20:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64F1368A22C for ; Sat, 1 Jan 2022 21:20:09 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id C1430E65E1; Sat, 1 Jan 2022 20:20:07 +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 ikzunh7zMtan; Sat, 1 Jan 2022 20:20:06 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7B635E64BA; Sat, 1 Jan 2022 20:20:06 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Jan 2022 20:20:00 +0100 Message-Id: <20220101192001.13688-1-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/imfdec: 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +UsYL1kOJR+7 Signed-off-by: Marton Balint --- libavformat/imfdec.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index f17064cfcd..ef1e7cf206 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -73,8 +73,6 @@ #include #include -#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) -#define DEFAULT_ASSETMAP_SIZE 8 * 1024 #define AVRATIONAL_FORMAT "%d/%d" #define AVRATIONAL_ARG(rational) rational.num, rational.den @@ -279,7 +277,6 @@ static int parse_assetmap(AVFormatContext *s, const char *url) const char *base_url; char *tmp_str = NULL; int ret; - int64_t filesize; av_log(s, AV_LOG_DEBUG, "Asset Map URL: %s\n", url); @@ -289,13 +286,10 @@ static int parse_assetmap(AVFormatContext *s, const char *url) if (ret < 0) return ret; - filesize = avio_size(in); - filesize = filesize > 0 ? filesize : DEFAULT_ASSETMAP_SIZE; + av_bprint_init(&buf, 0, INT_MAX); // xmlReadMemory uses integer length - av_bprint_init(&buf, filesize + 1, AV_BPRINT_SIZE_UNLIMITED); - - ret = avio_read_to_bprint(in, &buf, MAX_BPRINT_READ_SIZE); - if (ret < 0 || !avio_feof(in) || buf.len == 0) { + ret = avio_read_to_bprint(in, &buf, SIZE_MAX); + if (ret < 0 || !avio_feof(in)) { av_log(s, AV_LOG_ERROR, "Unable to read to asset map '%s'\n", url); if (ret == 0) ret = AVERROR_INVALIDDATA; @@ -311,8 +305,7 @@ static int parse_assetmap(AVFormatContext *s, const char *url) } base_url = av_dirname(tmp_str); - filesize = buf.len; - doc = xmlReadMemory(buf.str, filesize, url, NULL, 0); + doc = xmlReadMemory(buf.str, buf.len, url, NULL, 0); ret = parse_imf_asset_map_from_xml_dom(s, doc, &c->asset_locator_map, base_url); if (!ret) From patchwork Sat Jan 1 19:20:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 32998 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp14945465iog; Sat, 1 Jan 2022 11:20:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTo7WHmkuTrmEQQxmJxAi53WlqVRDBiIdtkFRd4LeUbAzKGkD+iflsD1I1tpj9x19hQEOU X-Received: by 2002:a05:6402:35d2:: with SMTP id z18mr38450857edc.100.1641064831515; Sat, 01 Jan 2022 11:20:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641064831; cv=none; d=google.com; s=arc-20160816; b=vUFQnj5/xJk4jR082BRkm9xTgTCIzP3RblS/UrBUp7yKAvAs75T851X+NIEn8+8kVq tyP9Hk5R1KxSewC+rTrG/pOc342uzSezZAtQsXeVlydiNi0LSbncR9LXcjw54rxbALa/ xc5f3yECdnDwyuumdCiHnHKGrisUnskuTqWCUrYHViXRHXkSRmnD7qGH6BF8uq9CgO8d aik+EFtrxrSNWRKlH8u1T4azHbGdwqpWkPWpJVl9Jkk2OSaMUG2C3vWOmi4VwRSz2Inq kTlUP3oN9YDeO/qSdN/kpeQ7sKJlK3ys2z4bPuxUO2gxnglRex+HEdu9Z/fFB8nlGjQT cYAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=qnDsmgB3OzpM0E96yRbhTrASJJKVU8G7Ivq2GED7RhI=; b=tpXag9MSrrocvJpvfkQMTVEJeqx1gqLMYxKTswXesOJA1sZUYoBxgw23sJdJYRo+5J /dUbkKCIk926HVRuXTiMHB6hr858BB518XUVqfjnvW25Y/TMTh4ZQ+O0b+/TVbW2epVx CImm13ZuVFpYSSouHsgZmOcBlhe1d3WJr1MLIGYV8VFUZc6gdKtcmBk1HqLgN92ajZnD ylnYJVfrfEpFETjhub67rMw3ypjo/XTYw2phTYPSGdCsUpyAvIV0OMLt4F3DKPHBgH7j A9z2BWgPKVkrfdNEOPr8FVaaYMHT5MkM+mkG6b60wsrX9mo7Be3gE4hMRopa6PWyaFEF K2HA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y4si17342885edi.324.2022.01.01.11.20.31; Sat, 01 Jan 2022 11:20:31 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5121A68B143; Sat, 1 Jan 2022 21:20:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Iuy4CmnDQd4w 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;