diff mbox series

[FFmpeg-devel,06/11] avformat/matroskadec: Simplify checks for cook and ATRAC3

Message ID 20200423030741.12158-6-andreas.rheinhardt@gmail.com
State Accepted
Commit 4b1c19a054432b4a5bc3e90b8c186dc25a416ebd
Headers show
Series [FFmpeg-devel,01/11] avformat/matroskadec: Reject sipr flavor > 3
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 23, 2020, 3:07 a.m. UTC
Some conditions which don't change and which can therefore be checked
in read_header() were instead rechecked upon parsing each block. This
has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/matroskadec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 1dc0b77962..5643e15a20 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2624,7 +2624,8 @@  static int matroska_parse_tracks(AVFormatContext *s)
                         return AVERROR_INVALIDDATA;
                     track->audio.sub_packet_size = ff_sipr_subpk_size[flavor];
                     st->codecpar->bit_rate          = sipr_bit_rate[flavor];
-                } else if (track->audio.sub_packet_size <= 0)
+                } else if (track->audio.sub_packet_size <= 0 ||
+                           track->audio.frame_size % track->audio.sub_packet_size)
                     return AVERROR_INVALIDDATA;
                 st->codecpar->block_align = track->audio.sub_packet_size;
                 extradata_offset       = 78;
@@ -3138,7 +3139,7 @@  static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
             }
             memcpy(track->audio.buf + y * w, data, w);
         } else {
-            if (size < sps * w / sps || h<=0 || w%sps) {
+            if (size < w) {
                 av_log(matroska->ctx, AV_LOG_ERROR,
                        "Corrupt generic RM-style audio packet size\n");
                 return AVERROR_INVALIDDATA;