Browse code

avcodec/utils: Better check for channels in av_get_audio_frame_duration()

Fixes integer overflow
Fixes: 0c2625f236ced104d402b4a03c0d65c7/asan_generic_274e1ce_5990_9314e7a67c26aecf011b178ade9f217c.avi

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4e16ad2868a1819de6680fc355a8eb20164adaea)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2015/11/14 09:35:08
Showing 1 changed files
... ...
@@ -3490,7 +3490,7 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
3490 3490
                 return frame_bytes * 8 / bps;
3491 3491
         }
3492 3492
 
3493
-        if (ch > 0) {
3493
+        if (ch > 0 && ch < INT_MAX/16) {
3494 3494
             /* calc from frame_bytes and channels */
3495 3495
             switch (id) {
3496 3496
             case AV_CODEC_ID_ADPCM_AFC: