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 435AE40855 for ; Mon, 31 Jan 2022 23:13:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 106E968B160; Tue, 1 Feb 2022 01:13:49 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 75F1968094F for ; Tue, 1 Feb 2022 01:13:42 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 63DD7E4D1D; Tue, 1 Feb 2022 00:13:42 +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 1SZYyUJ1EAw8; Tue, 1 Feb 2022 00:13:41 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F270EE216B; Tue, 1 Feb 2022 00:13:40 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 00:13:34 +0100 Message-Id: <20220131231334.29017-1-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/imf_cpl: 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: Similar to the earlier patch applied to imfdec. Signed-off-by: Marton Balint --- libavformat/imf_cpl.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index f2ad9c05d6..102a6b4549 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -797,13 +797,11 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl) AVBPrint buf; xmlDoc *doc = NULL; int ret = 0; - int64_t filesize = 0; - filesize = avio_size(in); - filesize = filesize > 0 ? filesize : 8192; - av_bprint_init(&buf, filesize + 1, AV_BPRINT_SIZE_UNLIMITED); - ret = avio_read_to_bprint(in, &buf, UINT_MAX - 1); - if (ret < 0 || !avio_feof(in) || buf.len == 0) { + av_bprint_init(&buf, 0, INT_MAX); // xmlReadMemory uses integer length + + ret = avio_read_to_bprint(in, &buf, SIZE_MAX); + if (ret < 0 || !avio_feof(in)) { av_log(NULL, AV_LOG_ERROR, "Cannot read IMF CPL\n"); if (ret == 0) ret = AVERROR_INVALIDDATA; @@ -812,8 +810,7 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl) LIBXML_TEST_VERSION - filesize = buf.len; - doc = xmlReadMemory(buf.str, filesize, NULL, NULL, 0); + doc = xmlReadMemory(buf.str, buf.len, NULL, NULL, 0); if (!doc) { av_log(NULL, AV_LOG_ERROR, -- 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".