[gimp] plug-ins: don't try to read tiff pages with an invalid directory.
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: don't try to read tiff pages with an invalid directory.
- Date: Sat, 24 Oct 2020 17:52:54 +0000 (UTC)
commit e4514567f9ff675271670f28a3cf523e49832ff3
Author: Jacob Boerema <jgboerema gmail com>
Date: Sat Oct 24 13:44:39 2020 -0400
plug-ins: don't try to read tiff pages with an invalid directory.
We didn't check whether TIFFSetDirectory succeeded nor did
we check TIFFReadScanline for failure which can cause
unresponsiveness.
We will not try to read a tiff page if setting its directory fails
and we will stop reading a page if reading scanline fails.
plug-ins/file-tiff/file-tiff-load.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c
index 27235761fc..ba6c1d8226 100644
--- a/plug-ins/file-tiff/file-tiff-load.c
+++ b/plug-ins/file-tiff/file-tiff-load.c
@@ -329,7 +329,12 @@ load_image (GFile *file,
gint gimp_compression = GIMP_COMPRESSION_NONE;
const gchar *name;
- TIFFSetDirectory (tif, pages.pages[li]);
+ if (TIFFSetDirectory (tif, pages.pages[li]) == 0)
+ {
+ g_message (_("Couldn't read page %d of %d. Image might be corrupt.\n"),
+ li+1, pages.n_pages);
+ continue;
+ }
ilayer = pages.pages[li];
gimp_progress_update (0.0);
@@ -1600,8 +1605,14 @@ load_contiguous (TIFF *tif,
if (TIFFIsTiled (tif))
TIFFReadTile (tif, buffer, x, y, 0, 0);
- else
- TIFFReadScanline (tif, buffer, y, 0);
+ else if (TIFFReadScanline (tif, buffer, y, 0) == -1)
+ {
+ /* Error reading scanline, stop loading */
+ g_printerr ("Reading scanline failed. Image may be corrupt at line %d.\n", y);
+ g_free (buffer);
+ g_free (bw_buffer);
+ return;
+ }
cols = MIN (image_width - x, tile_width);
rows = MIN (image_height - y, tile_height);
@@ -1769,8 +1780,14 @@ load_separate (TIFF *tif,
if (TIFFIsTiled (tif))
TIFFReadTile (tif, buffer, x, y, 0, compindex);
- else
- TIFFReadScanline (tif, buffer, y, compindex);
+ else if (TIFFReadScanline (tif, buffer, y, compindex) == -1)
+ {
+ /* Error reading scanline, stop loading */
+ g_printerr ("Reading scanline failed. Image may be corrupt at line %d.\n", y);
+ g_free (buffer);
+ g_free (bw_buffer);
+ return;
+ }
cols = MIN (image_width - x, tile_width);
rows = MIN (image_height - y, tile_height);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]