[FFmpeg-cvslog] avformat/matroskaenc: Check BlockAdditional size before use
Andreas Rheinhardt
git at videolan.org
Sat Mar 14 23:11:32 EET 2020
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Jan 26 06:10:27 2020 +0100| [6e9cc964293bf1e0cca6a52b2938a20d711e4146] | committer: Michael Niedermayer
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 at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e9cc964293bf1e0cca6a52b2938a20d711e4146
---
libavformat/matroskaenc.c | 10 +++++++---
1 file 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) {
More information about the ffmpeg-cvslog
mailing list