Commit 4744f67d authored by Paul B Mahol's avatar Paul B Mahol

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: 's avatarPaul B Mahol <onemda@gmail.com>
parent e6ef628b
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#define WV_FLT_ZERO_SENT 0x08 #define WV_FLT_ZERO_SENT 0x08
#define WV_FLT_ZERO_SIGN 0x10 #define WV_FLT_ZERO_SIGN 0x10
#define WV_MAX_SAMPLES 131072
enum WP_ID_Flags { enum WP_ID_Flags {
WP_IDF_MASK = 0x1F, WP_IDF_MASK = 0x1F,
WP_IDF_IGNORE = 0x20, WP_IDF_IGNORE = 0x20,
...@@ -1190,7 +1192,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1190,7 +1192,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data,
frame_flags = AV_RL32(buf + 4); 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", av_log(avctx, AV_LOG_ERROR, "Invalid number of samples: %d\n",
s->samples); s->samples);
return AVERROR(EINVAL); return AVERROR(EINVAL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment