[gimp/gimp-2-6] Ensure valid bit depths when reading BMP files.



commit 153ae579f7e7508d7a5b95bd569e91890f6b666e
Author: Nils Philippsen <nils redhat com>
Date:   Mon Nov 16 18:16:38 2009 +0100

    Ensure valid bit depths when reading BMP files.
    (cherry picked from commit 16e6a37687bb4b9748c5a5d166d90f5d5bd2e9f3)

 plug-ins/file-bmp/bmp-read.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/file-bmp/bmp-read.c b/plug-ins/file-bmp/bmp-read.c
index 76c4f5d..7ac4cc4 100644
--- a/plug-ins/file-bmp/bmp-read.c
+++ b/plug-ins/file-bmp/bmp-read.c
@@ -400,9 +400,26 @@ ReadBMP (const gchar  *name,
         }
     }
 
-  /* Valid bitpdepthis 1, 4, 8, 16, 24, 32 */
+  /* Valid bit depth is 1, 4, 8, 16, 24, 32 */
   /* 16 is awful, we should probably shoot whoever invented it */
 
+  switch (Bitmap_Head.biBitCnt)
+    {
+    case 1:
+    case 2:
+    case 4:
+    case 8:
+    case 16:
+    case 24:
+    case 32:
+      break;
+    default:
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                   _("'%s' is not a valid BMP file"),
+                   gimp_filename_to_utf8 (filename));
+      return -1;
+    }
+
   /* There should be some colors used! */
 
   ColormapSize =



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