~ubuntu-branches/ubuntu/precise/freetype/precise-security

« back to all changes in this revision

Viewing changes to debian/patches-freetype/CVE-2014-96xx/CVE-2014-9661-1.patch

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-02-24 10:35:56 UTC
  • Revision ID: package-import@ubuntu.com-20150224103556-1gtuu5oa9cjuzioh
Tags: 2.4.8-1ubuntu2.2
* SECURITY UPDATE: denial of service and possible code execution via
  multiple security issues
  - debian/patches-freetype/CVE-2014-96xx/*.patch: backport a large
    quantity of upstream commits to fix multiple security issues.
  - CVE-2014-9656
  - CVE-2014-9657
  - CVE-2014-9658
  - CVE-2014-9660
  - CVE-2014-9661
  - CVE-2014-9663
  - CVE-2014-9664
  - CVE-2014-9666
  - CVE-2014-9667
  - CVE-2014-9669
  - CVE-2014-9670
  - CVE-2014-9671
  - CVE-2014-9672
  - CVE-2014-9673
  - CVE-2014-9674
  - CVE-2014-9675

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Backport of:
 
2
 
 
3
From 3788187e0c396952cd7d905c6c61f3ff8e84b2b4 Mon Sep 17 00:00:00 2001
 
4
From: Werner Lemberg <wl@gnu.org>
 
5
Date: Sat, 22 Nov 2014 09:46:47 +0000
 
6
Subject: [type42] Fix Savannah bug #43659.
 
7
 
 
8
* src/type42/t42objs.c (T42_Open_Face): Initialize `face->ttf_size'.
 
9
 
 
10
* src/type42/t42parse.c (t42_parse_sfnts): Always set
 
11
`face->ttf_size' directly.  This ensures a correct stream size in
 
12
the call to `FT_Open_Face', which follows after parsing, even for
 
13
buggy input data.
 
14
Fix error messages.
 
15
---
 
16
Index: freetype-2.4.8/src/type42/t42objs.c
 
17
===================================================================
 
18
--- freetype-2.4.8.orig/src/type42/t42objs.c    2015-02-24 09:57:33.071500298 -0500
 
19
+++ freetype-2.4.8/src/type42/t42objs.c 2015-02-24 09:57:33.067500267 -0500
 
20
@@ -47,6 +47,12 @@
 
21
     if ( FT_ALLOC( face->ttf_data, 12 ) )
 
22
       goto Exit;
 
23
 
 
24
+    /* while parsing the font we always update `face->ttf_size' so that */
 
25
+    /* even in case of buggy data (which might lead to premature end of */
 
26
+    /* scanning without causing an error) the call to `FT_Open_Face' in */
 
27
+    /* `T42_Face_Init' passes the correct size                          */
 
28
+    face->ttf_size = 12;
 
29
+
 
30
     error = t42_parser_init( parser,
 
31
                              face->root.stream,
 
32
                              memory,
 
33
Index: freetype-2.4.8/src/type42/t42parse.c
 
34
===================================================================
 
35
--- freetype-2.4.8.orig/src/type42/t42parse.c   2015-02-24 09:57:33.071500298 -0500
 
36
+++ freetype-2.4.8/src/type42/t42parse.c        2015-02-24 10:00:32.536900770 -0500
 
37
@@ -499,7 +499,7 @@
 
38
     FT_Byte*    limit  = parser->root.limit;
 
39
     FT_Error    error;
 
40
     FT_Int      num_tables = 0;
 
41
-    FT_ULong    count, ttf_size = 0;
 
42
+    FT_ULong    count;
 
43
 
 
44
     FT_Long     n, string_size, old_string_size, real_size;
 
45
     FT_Byte*    string_buf = NULL;
 
46
@@ -592,7 +592,7 @@
 
47
 
 
48
         if ( limit - parser->root.cursor < string_size )
 
49
         {
 
50
-          FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
 
51
+          FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
 
52
           error = T42_Err_Invalid_File_Format;
 
53
           goto Fail;
 
54
         }
 
55
@@ -632,18 +632,18 @@
 
56
           }
 
57
           else
 
58
           {
 
59
-            num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
 
60
-            status     = BEFORE_TABLE_DIR;
 
61
-            ttf_size   = 12 + 16 * num_tables;
 
62
+            num_tables     = 16 * face->ttf_data[4] + face->ttf_data[5];
 
63
+            status         = BEFORE_TABLE_DIR;
 
64
+            face->ttf_size = 12 + 16 * num_tables;
 
65
 
 
66
-            if ( FT_REALLOC( face->ttf_data, 12, ttf_size ) )
 
67
+            if ( FT_REALLOC( face->ttf_data, 12, face->ttf_size ) )
 
68
               goto Fail;
 
69
           }
 
70
           /* fall through */
 
71
 
 
72
         case BEFORE_TABLE_DIR:
 
73
           /* the offset table is read; read the table directory */
 
74
-          if ( count < ttf_size )
 
75
+          if ( count < face->ttf_size )
 
76
           {
 
77
             face->ttf_data[count++] = string_buf[n];
 
78
             continue;
 
79
@@ -662,24 +662,23 @@
 
80
               len = FT_PEEK_ULONG( p );
 
81
 
 
82
               /* Pad to a 4-byte boundary length */
 
83
-              ttf_size += ( len + 3 ) & ~3;
 
84
+              face->ttf_size += ( len + 3 ) & ~3;
 
85
             }
 
86
 
 
87
-            status         = OTHER_TABLES;
 
88
-            face->ttf_size = ttf_size;
 
89
+            status = OTHER_TABLES;
 
90
 
 
91
             /* there are no more than 256 tables, so no size check here */
 
92
             if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
 
93
-                             ttf_size + 1 ) )
 
94
+                             face->ttf_size + 1 ) )
 
95
               goto Fail;
 
96
           }
 
97
           /* fall through */
 
98
 
 
99
         case OTHER_TABLES:
 
100
           /* all other tables are just copied */
 
101
-          if ( count >= ttf_size )
 
102
+          if ( count >= face->ttf_size )
 
103
           {
 
104
-            FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
 
105
+            FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
 
106
             error = T42_Err_Invalid_File_Format;
 
107
             goto Fail;
 
108
           }