[FFmpeg-cvslog] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions

Michael Niedermayer git at videolan.org
Wed Apr 6 21:33:11 EEST 2022


ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Fri Dec 17 20:52:32 2021 +0100| [14249d8a0376ce7d4d40eba0ee81c5973eb4441a] | committer: Michael Niedermayer

avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions

sets coded_width / coded_height too to keep them consistent with
width / height

Fixes: OOM
Fixes: 42263/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5653333619113984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit cfa1f0e214d07f0fdc027f2ec760eb9fd3fac85e)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=14249d8a0376ce7d4d40eba0ee81c5973eb4441a
---

 libavcodec/tiff.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 7d65da8e9a..6faf451c68 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -738,13 +738,14 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame,
 static int dng_decode_strip(AVCodecContext *avctx, AVFrame *frame)
 {
     TiffContext *s = avctx->priv_data;
+    int ret = ff_set_dimensions(s->avctx_mjpeg, s->width, s->height);
+
+    if (ret < 0)
+        return ret;
 
     s->jpgframe->width  = s->width;
     s->jpgframe->height = s->height;
 
-    s->avctx_mjpeg->width = s->width;
-    s->avctx_mjpeg->height = s->height;
-
     return dng_decode_jpeg(avctx, frame, s->stripsize, 0, 0, s->width, s->height);
 }
 
@@ -985,14 +986,14 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
     int has_width_leftover, has_height_leftover;
     int tile_x = 0, tile_y = 0;
     int pos_x = 0, pos_y = 0;
-    int ret;
+    int ret = ff_set_dimensions(s->avctx_mjpeg, s->tile_width, s->tile_length);
+
+    if (ret < 0)
+        return ret;
 
     s->jpgframe->width  = s->tile_width;
     s->jpgframe->height = s->tile_length;
 
-    s->avctx_mjpeg->width = s->tile_width;
-    s->avctx_mjpeg->height = s->tile_length;
-
     has_width_leftover = (s->width % s->tile_width != 0);
     has_height_leftover = (s->height % s->tile_length != 0);
 



More information about the ffmpeg-cvslog mailing list