191ad33
diff -urNp old/plug-ins/common/file-psp.c new/plug-ins/common/file-psp.c
191ad33
--- old/plug-ins/common/file-psp.c	2018-01-04 12:04:14.636811394 +0100
191ad33
+++ new/plug-ins/common/file-psp.c	2018-01-04 12:12:41.717877789 +0100
191ad33
@@ -1777,6 +1777,15 @@ load_image (const gchar  *filename,
191ad33
     {
191ad33
       block_start = ftell (f);
191ad33
 
191ad33
+      if (block_start + block_total_len > st.st_size)
191ad33
+        {
191ad33
+          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
191ad33
+                       _("Could not open '%s' for reading: %s"),
191ad33
+                       gimp_filename_to_utf8 (filename),
191ad33
+                       _("invalid block size"));
191ad33
+          goto error;
191ad33
+        }
191ad33
+
191ad33
       if (id == PSP_IMAGE_BLOCK)
191ad33
         {
191ad33
           if (block_number != 0)