[FFmpeg-devel,1/2] avcodec/diracdec: Check perspective_exp and zrs_exp.

Submitted by Michael Niedermayer on Aug. 15, 2017, 1:32 a.m.

Details

Message ID 20170815013244.21614-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Aug. 15, 2017, 1:32 a.m.
Fixes: undefined shift
Fixes: runtime error: shift exponent 264 is too large for 32-bit type 'int'
Fixes: 2860/clusterfuzz-testcase-minimized-4672811689836544

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

Comments

Michael Niedermayer Aug. 16, 2017, 4:21 p.m.
On Tue, Aug 15, 2017 at 03:32:43AM +0200, Michael Niedermayer wrote:
> Fixes: undefined shift
> Fixes: runtime error: shift exponent 264 is too large for 32-bit type 'int'
> Fixes: 2860/clusterfuzz-testcase-minimized-4672811689836544
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/diracdec.c | 5 +++++
>  1 file changed, 5 insertions(+)

applied

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index f2837aca69..be8b282314 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -1161,6 +1161,11 @@  static int dirac_unpack_prediction_parameters(DiracContext *s)
                 s->globalmc[ref].perspective[0]  = dirac_get_se_golomb(gb);
                 s->globalmc[ref].perspective[1]  = dirac_get_se_golomb(gb);
             }
+            if (s->globalmc[ref].perspective_exp + (uint64_t)s->globalmc[ref].zrs_exp > 30) {
+                av_log(s->avctx, AV_LOG_ERROR, "exp %d %d too large\n", s->globalmc[ref].perspective_exp, s->globalmc[ref].zrs_exp);
+                return AVERROR_INVALIDDATA;
+            }
+
         }
     }