|
| 1 | +From fc4ebc5b677362b31817f71e8c155d186f8efaa7 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Sat, 2 Aug 2025 18:55:54 +0200 |
| 4 | +Subject: [PATCH] tiff2ps: check return of TIFFGetFiled() for |
| 5 | + TIFFTAG_STRIPBYTECOUNTS and TIFFTAG_TILEBYTECOUNTS to avoid NULL pointer |
| 6 | + dereference. |
| 7 | + |
| 8 | +Closes #718 |
| 9 | + |
| 10 | +Signed-off-by: Azure Linux Security Servicing Account < [email protected]> |
| 11 | +Upstream-reference: https://gitlab.com/libtiff/libtiff/-/commit/6ba36f159fd396ad11bf6b7874554197736ecc8b.patch |
| 12 | +--- |
| 13 | + tools/unsupported/tiff2ps.c | 20 +++++++++++++++++--- |
| 14 | + 1 file changed, 17 insertions(+), 3 deletions(-) |
| 15 | + |
| 16 | +diff --git a/tools/unsupported/tiff2ps.c b/tools/unsupported/tiff2ps.c |
| 17 | +index 541495d..d6a54b4 100644 |
| 18 | +--- a/tools/unsupported/tiff2ps.c |
| 19 | ++++ b/tools/unsupported/tiff2ps.c |
| 20 | +@@ -2432,12 +2432,22 @@ int PS_Lvl2page(FILE *fd, TIFF *tif, uint32_t w, uint32_t h) |
| 21 | + if (tiled_image) |
| 22 | + { |
| 23 | + num_chunks = TIFFNumberOfTiles(tif); |
| 24 | +- TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &bc); |
| 25 | ++ if (!TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &bc)) |
| 26 | ++ { |
| 27 | ++ TIFFError(filename, |
| 28 | ++ "Can't read bytecounts of tiles at PS_Lvl2page()"); |
| 29 | ++ return (FALSE); |
| 30 | ++ } |
| 31 | + } |
| 32 | + else |
| 33 | + { |
| 34 | + num_chunks = TIFFNumberOfStrips(tif); |
| 35 | +- TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); |
| 36 | ++ if (!TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc)) |
| 37 | ++ { |
| 38 | ++ TIFFError(filename, |
| 39 | ++ "Can't read bytecounts of strips at PS_Lvl2page()"); |
| 40 | ++ return (FALSE); |
| 41 | ++ } |
| 42 | + } |
| 43 | + |
| 44 | + if (use_rawdata) |
| 45 | +@@ -3107,7 +3117,11 @@ void PSRawDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h) |
| 46 | + (void)w; |
| 47 | + (void)h; |
| 48 | + TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); |
| 49 | +- TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); |
| 50 | ++ if (!TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc)) |
| 51 | ++ { |
| 52 | ++ TIFFError(filename, "Can't read bytecounts of strips at PSRawDataBW()"); |
| 53 | ++ return; |
| 54 | ++ } |
| 55 | + |
| 56 | + /* |
| 57 | + * Find largest strip: |
| 58 | +-- |
| 59 | +2.45.4 |
| 60 | + |
0 commit comments