[FFmpeg-devel] [PATCH 1/2] avcodec/tiff: Avoid 0.0/0.0 in camera_xyz_coeff()

Michael Niedermayer michael at niedermayer.cc
Fri Nov 18 01:14:17 EET 2022


Fixes: division by zero
Fixes: 52230/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5922608915021824

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 5b56892071..cde318d5e5 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1896,6 +1896,8 @@ static void camera_xyz_coeff(TiffContext *s,
     for (i = 0; i < 3; i++) {
         for (num = j = 0; j < 3; j++)
             num += cam2rgb[i][j];
+        if (!num)
+            num = 1;
         for (j = 0; j < 3; j++)
             cam2rgb[i][j] /= num;
         s->premultiply[i] = 1.f / num;
-- 
2.17.1



More information about the ffmpeg-devel mailing list