1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/kvag: Check sample_rate

Fixes: Division by 0
Fixes: -copyts -start_at_zero -itsoffset 00:00:01 -itsscale 1 -ss 00:00:02  -i zgclab/ffmpeg_crash/poc1 output.mp4

Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c26a762ea1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2024-04-29 23:44:25 +02:00
parent e67741feea
commit 115853a821
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -37,7 +37,7 @@
typedef struct KVAGHeader {
uint32_t magic;
uint32_t data_size;
uint32_t sample_rate;
int sample_rate;
uint16_t stereo;
} KVAGHeader;
@ -69,6 +69,9 @@ static int kvag_read_header(AVFormatContext *s)
hdr.sample_rate = AV_RL32(buf + 8);
hdr.stereo = AV_RL16(buf + 12);
if (hdr.sample_rate <= 0)
return AVERROR_INVALIDDATA;
par = st->codecpar;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->codec_id = AV_CODEC_ID_ADPCM_IMA_SSI;