From 719c557c9a29db32b855e6e108d7f4e7c5397613 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Mon, 10 Nov 2025 18:46:10 +0100 Subject: [PATCH] Reject images where the number of samples does not correspond with the color space 3. fix for CVE-2025-57812 --- cupsfilters/image-tiff.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cupsfilters/image-tiff.c b/cupsfilters/image-tiff.c index 48fc8a28b..a207f7ce9 100644 --- a/cupsfilters/image-tiff.c +++ b/cupsfilters/image-tiff.c @@ -204,6 +204,23 @@ _cupsImageReadTIFF( else alpha = 0; + /* + * Check whether number of samples per pixel corresponds with color space + */ + + if ((photometric == PHOTOMETRIC_RGB && (samples < 3 || samples > 4)) || + (photometric == PHOTOMETRIC_SEPARATED && samples != 4)) + { + fprintf(stderr, "DEBUG: Number of samples per pixel does not correspond to color space! " + "Color space: %s; Samples per pixel: %d\n", + (photometric == PHOTOMETRIC_RGB ? "RGB" : + (photometric == PHOTOMETRIC_SEPARATED ? "CMYK" : "Unknown")), + samples); + TIFFClose(tif); + fclose(fp); + return (1); + } + /* * Check the size of the image... */