diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-01-26 06:10:27 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-03-14 22:07:27 +0100 |
commit | 6e9cc964293bf1e0cca6a52b2938a20d711e4146 (patch) | |
tree | 98db95a4d2e44b152155d1d95a830a6bef8c98e0 | |
parent | b49af89e032c517e1a90bfb9fe1af731ed843c13 (diff) |
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>
-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 42f21eae8b..9be086237a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2142,9 +2142,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) { |