diff mbox series

[FFmpeg-devel,1/2] avcodec/snowdec: Sanity check hcoeff

Message ID 20200806211816.9582-1-michael@niedermayer.cc
State Accepted
Commit d51d569cf68f78aaea8464a156c847a0e294726a
Headers show
Series [FFmpeg-devel,1/2] avcodec/snowdec: Sanity check hcoeff
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer Aug. 6, 2020, 9:18 p.m. UTC
Fixes: signed integer overflow: -2147483648 * -1 cannot be represented in type 'int'
Fixes: 24011/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5486376610168832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/snowdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Aug. 7, 2020, 10:05 a.m. UTC | #1
On Thu, Aug 06, 2020 at 11:18:15PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483648 * -1 cannot be represented in type 'int'
> Fixes: 24011/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5486376610168832
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/snowdec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index 88664dc472..5e69f39022 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -369,7 +369,10 @@  static int decode_header(SnowContext *s){
                 htaps = htaps*2 + 2;
                 p->htaps= htaps;
                 for(i= htaps/2; i; i--){
-                    p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1));
+                    unsigned hcoeff = get_symbol(&s->c, s->header_state, 0);
+                    if (hcoeff > 127)
+                        return AVERROR_INVALIDDATA;
+                    p->hcoeff[i]= hcoeff * (1-2*(i&1));
                     sum += p->hcoeff[i];
                 }
                 p->hcoeff[0]= 32-sum;