|
| 1 | +From 1c89b020f452fb2e6da727e33faeab54b2095a04 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Wed, 11 Jun 2025 19:45:19 +0000 |
| 4 | +Subject: [PATCH] tif_getimage.c: Fix buffer underflow crash for less raster |
| 5 | + rows at TIFFReadRGBAImageOriented() |
| 6 | + |
| 7 | +Signed-off-by: Azure Linux Security Servicing Account < [email protected]> |
| 8 | +Upstream-reference: https://gitlab.com/libtiff/libtiff/-/commit/3e0dcf0ec651638b2bd849b2e6f3124b36890d99.patch |
| 9 | +--- |
| 10 | + libtiff/tif_getimage.c | 20 +++++++++++++++++--- |
| 11 | + 1 file changed, 17 insertions(+), 3 deletions(-) |
| 12 | + |
| 13 | +diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c |
| 14 | +index 6fee35d..08fdd5e 100644 |
| 15 | +--- a/libtiff/tif_getimage.c |
| 16 | ++++ b/libtiff/tif_getimage.c |
| 17 | +@@ -600,6 +600,22 @@ int TIFFRGBAImageGet(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, |
| 18 | + "No \"put\" routine setupl; probably can not handle image format"); |
| 19 | + return (0); |
| 20 | + } |
| 21 | ++ /* Verify raster width and height against image width and height. */ |
| 22 | ++ if (h > img->height) |
| 23 | ++ { |
| 24 | ++ /* Adapt parameters to read only available lines and put image at |
| 25 | ++ * the bottom of the raster. */ |
| 26 | ++ raster += (size_t)(h - img->height) * w; |
| 27 | ++ h = img->height; |
| 28 | ++ } |
| 29 | ++ if (w > img->width) |
| 30 | ++ { |
| 31 | ++ TIFFWarningExtR(img->tif, TIFFFileName(img->tif), |
| 32 | ++ "Raster width of %d shall not be larger than image " |
| 33 | ++ "width of %d -> raster width adapted for reading", |
| 34 | ++ w, img->width); |
| 35 | ++ w = img->width; |
| 36 | ++ } |
| 37 | + return (*img->get)(img, raster, w, h); |
| 38 | + } |
| 39 | + |
| 40 | +@@ -617,9 +633,7 @@ int TIFFReadRGBAImageOriented(TIFF *tif, uint32_t rwidth, uint32_t rheight, |
| 41 | + if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) |
| 42 | + { |
| 43 | + img.req_orientation = (uint16_t)orientation; |
| 44 | +- /* XXX verify rwidth and rheight against width and height */ |
| 45 | +- ok = TIFFRGBAImageGet(&img, raster + (rheight - img.height) * rwidth, |
| 46 | +- rwidth, img.height); |
| 47 | ++ ok = TIFFRGBAImageGet(&img, raster, rwidth, rheight); |
| 48 | + TIFFRGBAImageEnd(&img); |
| 49 | + } |
| 50 | + else |
| 51 | +-- |
| 52 | +2.45.4 |
| 53 | + |
0 commit comments