aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-01-26 06:10:27 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-07-02 23:56:12 +0200
commit94ca3a00c8b6d37f7b66f873041981506e95b6ea (patch)
tree639af4b028ce77dfa34351fdebf3e05e1ae9d7ba
parent4ed977bbe5b03e39a0f4218316063b4ec9732e21 (diff)
downloadffmpeg-94ca3a00c8b6d37f7b66f873041981506e95b6ea.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>
-rw-r--r--libavformat/matroskaenc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index d8b36435b9..a52b38731f 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2169,9 +2169,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) {