diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-01-14 00:51:42 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-01-19 11:34:36 +0100 |
commit | 0148e85c3ca143a3b7ae56e21f221cd78c334740 (patch) | |
tree | d395c3b39ea5867faedabb83041a1d68b387370d /libavformat | |
parent | b845fff57d358657d1c2efb63a883fb5505b6a32 (diff) | |
download | ffmpeg-0148e85c3ca143a3b7ae56e21f221cd78c334740.tar.gz |
avformat/matroskaenc: Don't waste bytes on SimpleTags length fields
Also check the (user-provided) tags for being overlong; the earlier
code had an implicit unchecked size_t->int conversion.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroskaenc.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 086d403c85..7bda9fdb6b 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1754,10 +1754,11 @@ static int mkv_write_tracks(AVFormatContext *s) static int mkv_write_simpletag(AVIOContext *pb, const AVDictionaryEntry *t) { + EBML_WRITER(4); uint8_t *key = av_strdup(t->key); uint8_t *p = key; const uint8_t *lang = NULL; - ebml_master tag; + int ret; if (!key) return AVERROR(ENOMEM); @@ -1775,15 +1776,15 @@ static int mkv_write_simpletag(AVIOContext *pb, const AVDictionaryEntry *t) p++; } - tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0); - put_ebml_string(pb, MATROSKA_ID_TAGNAME, key); + ebml_writer_open_master(&writer, MATROSKA_ID_SIMPLETAG); + ebml_writer_add_string(&writer, MATROSKA_ID_TAGNAME, key); if (lang) - put_ebml_string(pb, MATROSKA_ID_TAGLANG, lang); - put_ebml_string(pb, MATROSKA_ID_TAGSTRING, t->value); - end_ebml_master(pb, tag); + ebml_writer_add_string(&writer, MATROSKA_ID_TAGLANG, lang); + ebml_writer_add_string(&writer, MATROSKA_ID_TAGSTRING, t->value); + ret = ebml_writer_write(&writer, pb); av_freep(&key); - return 0; + return ret; } static int mkv_write_tag_targets(MatroskaMuxContext *mkv, AVIOContext **pb, |