commit c7178633e34063af372f5de7cd6e529913b238b3
Author: Nils Philippsen <nils@redhat.com>
Date:   Mon Nov 16 12:06:46 2009 +0100

    Make type overflow checks more defensive.
    
    Use divisions instead of multiplications for checking against type
    boundaries as they cannot overflow.

diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index 197da4a..ee271cd 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -303,7 +303,7 @@ read_header_block (PSDimage  *img_a,
       return -1;
     }
 
-  if (((guint64) img_a->columns) * img_a->rows > G_MAXINT32)
+  if (img_a->columns > G_MAXINT32 / img_a->rows)
     {
       g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                    _("Unsupported or invalid image size: %dx%d"),
@@ -1810,7 +1810,7 @@ read_channel_data (PSDchannel     *channel,
                     channel->rows, readline_len * channel->rows);
 
   /* int overflow check */
-  if (((gint64) channel->rows) * channel->columns * MAX (bps >> 3, 1) > G_MAXINT32)
+  if (channel->rows > G_MAXINT32 / channel->columns / MAX (bps >> 3, 1))
     {
       g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                    _("Unsupported or invalid channel size"));
