diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-01-26 06:10:27 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-07-02 10:15:06 +0200 |
commit | 7fb1978249402e3f327662a629d83de64331a9c3 (patch) | |
tree | cab0bc181fca8a63f6062e607d20aaa78def8a8d /libavformat/matroskaenc.c | |
parent | dace04f5ad8eda4cdd5de8cfcba31c83ff15ff13 (diff) | |
download | ffmpeg-7fb1978249402e3f327662a629d83de64331a9c3.tar.gz |
avformat/matroskaenc: Check BlockAdditional size before use
Don't read a 64bit number before having checked that the data is at
least 8 bytes long.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6e9cc964293bf1e0cca6a52b2938a20d711e4146)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r-- | libavformat/matroskaenc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 4bc0aa1eca..fa33ccd23d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2154,9 +2154,13 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data) { - additional_id = AV_RB64(side_data); - side_data += 8; - side_data_size -= 8; + if (side_data_size < 8) { + side_data_size = 0; + } else { + additional_id = AV_RB64(side_data); + side_data += 8; + side_data_size -= 8; + } } if ((side_data_size && additional_id == 1) || discard_padding) { |