[gimp/gimp-2-6] Make plausibility check easier to understand.



commit 0214e1ff271a5310731de81d00450a92d9bf0fcd
Author: Nils Philippsen <nils redhat com>
Date:   Mon Nov 16 17:15:32 2009 +0100

    Make plausibility check easier to understand.
    
    Explicitly check that Bitmap_Head.biHeight is not G_MININT32
    instead of relying on ABS(G_MININT32) being negative.
    (cherry picked from commit 43d57c666346320436a0b668de5525387952784e)

 plug-ins/file-bmp/bmp-read.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/file-bmp/bmp-read.c b/plug-ins/file-bmp/bmp-read.c
index 7d7133a..c4e996a 100644
--- a/plug-ins/file-bmp/bmp-read.c
+++ b/plug-ins/file-bmp/bmp-read.c
@@ -424,8 +424,10 @@ ReadBMP (const gchar  *name,
       return -1;
     }
 
+  /* biHeight may be negative, but G_MININT32 is dangerous because:
+     G_MININT32 == -(G_MININT32) */
   if (Bitmap_Head.biWidth < 0 ||
-      ABS (Bitmap_Head.biHeight) < 0)
+      Bitmap_Head.biHeight == G_MININT32)
     {
       g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                    _("'%s' is not a valid BMP file"),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]