diff options
author | Paul B Mahol <onemda@gmail.com> | 2012-11-06 13:03:48 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2012-11-06 16:15:19 +0000 |
commit | 4744f67d4fe8669079af467c03f019c65fb2fd9f (patch) | |
tree | ef2c89e75ce0dd8a2f744215c0b914ae7a67c602 /libavcodec/wavpack.c | |
parent | e6ef628b1efb96d21e755a3750bb58d8042884ad (diff) | |
download | ffmpeg-4744f67d4fe8669079af467c03f019c65fb2fd9f.tar.gz |
wavpack: check if number of samples is not too big
Wavpack format documentation mentions that 131072 is
max number of samples.
This fixes huge memory allocations in sample from ticket #1889.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/wavpack.c')
-rw-r--r-- | libavcodec/wavpack.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index f3f7647dd0..253974e4b6 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -46,6 +46,8 @@ #define WV_FLT_ZERO_SENT 0x08 #define WV_FLT_ZERO_SIGN 0x10 +#define WV_MAX_SAMPLES 131072 + enum WP_ID_Flags { WP_IDF_MASK = 0x1F, WP_IDF_IGNORE = 0x20, @@ -1190,7 +1192,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data, frame_flags = AV_RL32(buf + 4); } } - if (s->samples <= 0) { + if (s->samples <= 0 || s->samples > WV_MAX_SAMPLES) { av_log(avctx, AV_LOG_ERROR, "Invalid number of samples: %d\n", s->samples); return AVERROR(EINVAL); |