~ubuntu-branches/ubuntu/oneiric/gimp/oneiric-security

« back to all changes in this revision

Viewing changes to debian/patches/02_CVE-2009-1570.patch

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-02-26 19:10:31 UTC
  • mfrom: (1.1.22 upstream) (0.4.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100226191031-d11l96bebdllen1n
Tags: 2.6.8-2ubuntu1
* Merge with debian, remaining changes:
  + debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch:
    - updated some strings for ubuntu
  + debian/rules:
    - updated translation templates
  + debian/control:
    - set Vcs-Bzr url

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
commit 57aedabfa3bc555e4d68ad916c757354d518b421
2
 
Author: Nils Philippsen <nils@redhat.com>
3
 
Date:   Tue Nov 17 11:52:25 2009 +0100
4
 
 
5
 
    patch: bmp-hardening
6
 
    
7
 
    Squashed commit of the following:
8
 
    
9
 
    commit d7ee36732bc37f4412c82f98473288fde2f6f151
10
 
    Author: Nils Philippsen <nils@redhat.com>
11
 
    Date:   Mon Nov 16 18:16:38 2009 +0100
12
 
    
13
 
        Ensure valid bit depths when reading BMP files.
14
 
        (cherry picked from commit 16e6a37687bb4b9748c5a5d166d90f5d5bd2e9f3)
15
 
        (cherry picked from commit 153ae579f7e7508d7a5b95bd569e91890f6b666e)
16
 
    
17
 
        Signed-off-by: Nils Philippsen <nils@redhat.com>
18
 
    
19
 
    commit b76b8400dfffd99826fe73dee81d76029b808689
20
 
    Author: Nils Philippsen <nils@redhat.com>
21
 
    Date:   Mon Nov 16 17:16:09 2009 +0100
22
 
    
23
 
        Use more defensive coding in plausibility check.
24
 
    
25
 
        Use an equivalent division instead of multiplying values and checking if
26
 
        they are more than G_MAXINT32, because divisions cannot overflow.
27
 
        (cherry picked from commit f63ba36dd9cc01ca6da83fa05ddd12419ad8953e)
28
 
        (cherry picked from commit 6e8ff603a2ee6a0940373723d1f075930dfd3ce0)
29
 
    
30
 
        Signed-off-by: Nils Philippsen <nils@redhat.com>
31
 
    
32
 
    commit c8bd5c99decca02158f9c0218b33fa057bfdf5ce
33
 
    Author: Nils Philippsen <nils@redhat.com>
34
 
    Date:   Mon Nov 16 17:15:32 2009 +0100
35
 
    
36
 
        Make plausibility check easier to understand.
37
 
    
38
 
        Explicitly check that Bitmap_Head.biHeight is not G_MININT32
39
 
        instead of relying on ABS(G_MININT32) being negative.
40
 
        (cherry picked from commit 43d57c666346320436a0b668de5525387952784e)
41
 
        (cherry picked from commit 0214e1ff271a5310731de81d00450a92d9bf0fcd)
42
 
    
43
 
        Signed-off-by: Nils Philippsen <nils@redhat.com>
44
 
    
45
 
    commit eec97e14def220b1de45dcece0a63eb9925f701f
46
 
    Author: Simon Budig <simon@gimp.org>
47
 
    Date:   Tue Nov 10 00:08:59 2009 +0100
48
 
    
49
 
        Harden the BMP plugin against integer overflows.
50
 
    
51
 
        Issues discovered by Stefan Cornelius, Secunia Research, advisory SA37232
52
 
        and CVE identifier CVE-2009-1570. Fixes bug #600484.
53
 
        (cherry picked from commit df2b0aca2e7cdb95ebfd3454c65aaba0a83e9bbe)
54
 
    
55
 
        Signed-off-by: Nils Philippsen <nils@redhat.com>
56
 
 
57
 
diff --git a/plug-ins/file-bmp/bmp-read.c b/plug-ins/file-bmp/bmp-read.c
58
 
index a1ebe47..7ac4cc4 100644
59
 
--- a/plug-ins/file-bmp/bmp-read.c
60
 
+++ b/plug-ins/file-bmp/bmp-read.c
61
 
@@ -400,9 +400,26 @@ ReadBMP (const gchar  *name,
62
 
         }
63
 
     }
64
 
 
65
 
-  /* Valid bitpdepthis 1, 4, 8, 16, 24, 32 */
66
 
+  /* Valid bit depth is 1, 4, 8, 16, 24, 32 */
67
 
   /* 16 is awful, we should probably shoot whoever invented it */
68
 
 
69
 
+  switch (Bitmap_Head.biBitCnt)
70
 
+    {
71
 
+    case 1:
72
 
+    case 2:
73
 
+    case 4:
74
 
+    case 8:
75
 
+    case 16:
76
 
+    case 24:
77
 
+    case 32:
78
 
+      break;
79
 
+    default:
80
 
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
81
 
+                   _("'%s' is not a valid BMP file"),
82
 
+                   gimp_filename_to_utf8 (filename));
83
 
+      return -1;
84
 
+    }
85
 
+
86
 
   /* There should be some colors used! */
87
 
 
88
 
   ColormapSize =
89
 
@@ -424,7 +441,10 @@ ReadBMP (const gchar  *name,
90
 
       return -1;
91
 
     }
92
 
 
93
 
-  if (Bitmap_Head.biWidth < 0)
94
 
+  /* biHeight may be negative, but G_MININT32 is dangerous because:
95
 
+     G_MININT32 == -(G_MININT32) */
96
 
+  if (Bitmap_Head.biWidth < 0 ||
97
 
+      Bitmap_Head.biHeight == G_MININT32)
98
 
     {
99
 
       g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
100
 
                    _("'%s' is not a valid BMP file"),
101
 
@@ -448,6 +468,18 @@ ReadBMP (const gchar  *name,
102
 
       return -1;
103
 
     }
104
 
 
105
 
+  /* protect against integer overflows caused by malicious BMPs */
106
 
+  /* use divisions in comparisons to avoid type overflows */
107
 
+
108
 
+  if (((guint64) Bitmap_Head.biWidth) > G_MAXINT32 / Bitmap_Head.biBitCnt ||
109
 
+      ((guint64) Bitmap_Head.biWidth) > (G_MAXINT32 / ABS (Bitmap_Head.biHeight)) / 4)
110
 
+    {
111
 
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
112
 
+                   _("'%s' is not a valid BMP file"),
113
 
+                   gimp_filename_to_utf8 (filename));
114
 
+      return -1;
115
 
+    }
116
 
+
117
 
   /* Windows and OS/2 declare filler so that rows are a multiple of
118
 
    * word length (32 bits == 4 bytes)
119
 
    */