1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avformat/wavdec: sanity check channels and bps before using them for block_align

Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-4704044498944000
Fixes: signed integer overflow: 520464 * 8224 cannot be represented in type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2024-03-26 00:45:09 +01:00
parent 0bed22d597
commit 75317ec442
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -34,6 +34,7 @@
#include "libavutil/log.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavcodec/internal.h"
#include "avformat.h"
#include "avio.h"
#include "avio_internal.h"
@ -908,7 +909,9 @@ static int w64_read_header(AVFormatContext *s)
if (ret < 0)
return ret;
avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
if (st->codecpar->block_align) {
if (st->codecpar->block_align &&
st->codecpar->ch_layout.nb_channels < FF_SANE_NB_CHANNELS &&
st->codecpar->bits_per_coded_sample < 128) {
int block_align = st->codecpar->block_align;
block_align = FFMAX(block_align,