From 44f45711ccbc6bdfcc047402d0e30eb7f3d6214c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Dec 2022 00:51:45 +0100 Subject: [PATCH] avcodec/tiff: Check camera_calibration for 0 Fixes: division by 0 Fixes: 53926/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5680347889401856 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/tiff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 41b5a6b7e4..820457fedc 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -2050,8 +2050,10 @@ again: } if (!s->use_color_matrix) { - for (i = 0; i < 3; i++) - s->premultiply[i] /= s->camera_calibration[i][i]; + for (i = 0; i < 3; i++) { + if (s->camera_calibration[i][i]) + s->premultiply[i] /= s->camera_calibration[i][i]; + } } else { for (int c = 0; c < 3; c++) { for (i = 0; i < 3; i++) {