diff mbox

[FFmpeg-devel,1/2] avcodec/tiff: Check stripsize strippos for overflow

Message ID 20170316020250.15175-1-michael@niedermayer.cc
State Accepted
Commit 5d996b56499f00f80b02a41bab3d6b7349e36e9d
Headers show

Commit Message

Michael Niedermayer March 16, 2017, 2:02 a.m. UTC
Fixes: 861/clusterfuzz-testcase-5688284384591872

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

Comments

Michael Niedermayer March 19, 2017, 11:55 p.m. UTC | #1
On Thu, Mar 16, 2017 at 03:02:49AM +0100, Michael Niedermayer wrote:
> Fixes: 861/clusterfuzz-testcase-5688284384591872
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/tiff.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

applied

[...]
diff mbox

Patch

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 0be7be7528..5a6573fb79 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -914,6 +914,11 @@  static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
         break;
     case TIFF_STRIP_OFFS:
         if (count == 1) {
+            if (value > INT_MAX) {
+                av_log(s->avctx, AV_LOG_ERROR,
+                    "strippos %u too large\n", value);
+                return AVERROR_INVALIDDATA;
+            }
             s->strippos = 0;
             s->stripoff = value;
         } else
@@ -925,6 +930,11 @@  static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
         break;
     case TIFF_STRIP_SIZE:
         if (count == 1) {
+            if (value > INT_MAX) {
+                av_log(s->avctx, AV_LOG_ERROR,
+                    "stripsize %u too large\n", value);
+                return AVERROR_INVALIDDATA;
+            }
             s->stripsizesoff = 0;
             s->stripsize     = value;
             s->strips        = 1;