[FFmpeg-cvslog] avformat/imfdec: do not use filesize when reading XML file
Marton Balint
git at videolan.org
Fri Apr 1 13:50:16 EEST 2022
ffmpeg | branch: release/5.0 | Marton Balint <cus at passwd.hu> | Sat Jan 1 20:05:59 2022 +0100| [d0e9e8c5d06442f65bde2a6231a586108d8b344b] | committer: Zane van Iperen
avformat/imfdec: do not use filesize when reading XML file
Signed-off-by: Marton Balint <cus at passwd.hu>
(cherry picked from commit ae690d5cf51d8b1b09f8ed6799041311cfa57a6b)
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0e9e8c5d06442f65bde2a6231a586108d8b344b
---
libavformat/imfdec.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 023f3556f6..566a0fb792 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -73,8 +73,6 @@
#include <inttypes.h>
#include <libxml/parser.h>
-#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)
More information about the ffmpeg-cvslog
mailing list