OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
8.0 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../freetype/CVE-2006-1861.patch
  5. # Copyright (C) 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- T2-COPYRIGHT-NOTE-END ---
  16. diff -Nur freetype-2.1.10-orig/include/freetype/fterrdef.h freetype-2.1.10/include/freetype/fterrdef.h
  17. --- freetype-2.1.10-orig/include/freetype/fterrdef.h 2004-02-12 08:33:20.000000000 +0000
  18. +++ freetype-2.1.10/include/freetype/fterrdef.h 2006-05-31 22:53:15.329323750 +0000
  19. @@ -4,7 +4,7 @@
  20. /* */
  21. /* FreeType error codes (specification). */
  22. /* */
  23. -/* Copyright 2002, 2004 by */
  24. +/* Copyright 2002, 2004, 2006 by */
  25. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  26. /* */
  27. /* This file is part of the FreeType project, and may only be used, */
  28. @@ -226,6 +226,8 @@
  29. "`ENCODING' field missing" )
  30. FT_ERRORDEF_( Missing_Bbx_Field, 0xB6, \
  31. "`BBX' field missing" )
  32. + FT_ERRORDEF_( Bbx_Too_Big, 0xB7, \
  33. + "`BBX' too big" )
  34. /* END */
  35. diff -Nur freetype-2.1.10-orig/src/bdf/bdflib.c freetype-2.1.10/src/bdf/bdflib.c
  36. --- freetype-2.1.10-orig/src/bdf/bdflib.c 2005-05-21 17:19:52.000000000 +0000
  37. +++ freetype-2.1.10/src/bdf/bdflib.c 2006-05-31 22:53:15.333324000 +0000
  38. @@ -1092,6 +1092,7 @@
  39. #define ERRMSG1 "[line %ld] Missing \"%s\" line.\n"
  40. #define ERRMSG2 "[line %ld] Font header corrupted or missing fields.\n"
  41. #define ERRMSG3 "[line %ld] Font glyphs corrupted or missing fields.\n"
  42. +#define ERRMSG4 "[line %ld] BBX too big.\n"
  43. static FT_Error
  44. @@ -1805,6 +1806,9 @@
  45. /* And finally, gather up the bitmap. */
  46. if ( ft_memcmp( line, "BITMAP", 6 ) == 0 )
  47. {
  48. + unsigned long bitmap_size;
  49. +
  50. +
  51. if ( !( p->flags & _BDF_BBX ) )
  52. {
  53. /* Missing BBX field. */
  54. @@ -1815,7 +1819,16 @@
  55. /* Allocate enough space for the bitmap. */
  56. glyph->bpr = ( glyph->bbx.width * p->font->bpp + 7 ) >> 3;
  57. - glyph->bytes = (unsigned short)( glyph->bpr * glyph->bbx.height );
  58. +
  59. + bitmap_size = glyph->bpr * glyph->bbx.height;
  60. + if ( bitmap_size > 0xFFFFU )
  61. + {
  62. + FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG4, lineno ));
  63. + error = BDF_Err_Bbx_Too_Big;
  64. + goto Exit;
  65. + }
  66. + else
  67. + glyph->bytes = (unsigned short)bitmap_size;
  68. if ( FT_NEW_ARRAY( glyph->bitmap, glyph->bytes ) )
  69. goto Exit;
  70. diff -Nur freetype-2.1.10-orig/src/cff/cffgload.c freetype-2.1.10/src/cff/cffgload.c
  71. --- freetype-2.1.10-orig/src/cff/cffgload.c 2005-04-18 04:53:05.000000000 +0000
  72. +++ freetype-2.1.10/src/cff/cffgload.c 2006-05-31 23:03:31.567836250 +0000
  73. @@ -2284,7 +2284,7 @@
  74. FT_LOCAL_DEF( FT_Error )
  75. cff_slot_load( CFF_GlyphSlot glyph,
  76. CFF_Size size,
  77. - FT_Int glyph_index,
  78. + FT_UInt glyph_index,
  79. FT_Int32 load_flags )
  80. {
  81. FT_Error error;
  82. @@ -2330,7 +2330,7 @@
  83. error = sfnt->load_sbit_image( face,
  84. (FT_ULong)size->strike_index,
  85. - (FT_UInt)glyph_index,
  86. + glyph_index,
  87. (FT_Int)load_flags,
  88. stream,
  89. &glyph->root.bitmap,
  90. @@ -2393,7 +2393,12 @@
  91. /* subsetted font, glyph_indices and CIDs are identical, though */
  92. if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
  93. cff->charset.cids )
  94. - glyph_index = cff->charset.cids[glyph_index];
  95. + {
  96. + if ( glyph_index < cff->charset.max_cid )
  97. + glyph_index = cff->charset.cids[glyph_index];
  98. + else
  99. + glyph_index = 0;
  100. + }
  101. cff_decoder_init( &decoder, face, size, glyph, hinting,
  102. FT_LOAD_TARGET_MODE( load_flags ) );
  103. diff -Nur freetype-2.1.10-orig/src/cff/cffgload.h freetype-2.1.10/src/cff/cffgload.h
  104. --- freetype-2.1.10-orig/src/cff/cffgload.h 2004-05-13 21:59:17.000000000 +0000
  105. +++ freetype-2.1.10/src/cff/cffgload.h 2006-05-31 22:53:24.161875750 +0000
  106. @@ -4,7 +4,7 @@
  107. /* */
  108. /* OpenType Glyph Loader (specification). */
  109. /* */
  110. -/* Copyright 1996-2001, 2002, 2003, 2004 by */
  111. +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
  112. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  113. /* */
  114. /* This file is part of the FreeType project, and may only be used, */
  115. @@ -196,7 +196,7 @@
  116. FT_LOCAL( FT_Error )
  117. cff_slot_load( CFF_GlyphSlot glyph,
  118. CFF_Size size,
  119. - FT_Int glyph_index,
  120. + FT_UInt glyph_index,
  121. FT_Int32 load_flags );
  122. diff -Nur freetype-2.1.10-orig/src/cff/cffload.c freetype-2.1.10/src/cff/cffload.c
  123. --- freetype-2.1.10-orig/src/cff/cffload.c 2005-05-06 05:49:46.000000000 +0000
  124. +++ freetype-2.1.10/src/cff/cffload.c 2006-05-31 22:53:24.161875750 +0000
  125. @@ -1688,6 +1688,8 @@
  126. for ( i = 0; i < num_glyphs; i++ )
  127. charset->cids[charset->sids[i]] = (FT_UShort)i;
  128. +
  129. + charset->max_cid = max_cid;
  130. }
  131. Exit:
  132. diff -Nur freetype-2.1.10-orig/src/cff/cfftypes.h freetype-2.1.10/src/cff/cfftypes.h
  133. --- freetype-2.1.10-orig/src/cff/cfftypes.h 2003-12-20 07:30:05.000000000 +0000
  134. +++ freetype-2.1.10/src/cff/cfftypes.h 2006-05-31 22:53:24.165876000 +0000
  135. @@ -5,7 +5,7 @@
  136. /* Basic OpenType/CFF type definitions and interface (specification */
  137. /* only). */
  138. /* */
  139. -/* Copyright 1996-2001, 2002, 2003 by */
  140. +/* Copyright 1996-2001, 2002, 2003, 2006 by */
  141. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  142. /* */
  143. /* This file is part of the FreeType project, and may only be used, */
  144. @@ -84,6 +84,7 @@
  145. FT_UShort* sids;
  146. FT_UShort* cids; /* the inverse mapping of `sids'; only needed */
  147. /* for CID-keyed fonts */
  148. + FT_UInt max_cid;
  149. } CFF_CharsetRec, *CFF_Charset;
  150. diff -Nur freetype-2.1.10-orig/src/sfnt/ttcmap.c freetype-2.1.10/src/sfnt/ttcmap.c
  151. --- freetype-2.1.10-orig/src/sfnt/ttcmap.c 2005-05-11 14:37:40.000000000 +0000
  152. +++ freetype-2.1.10/src/sfnt/ttcmap.c 2006-05-31 22:57:04.807665250 +0000
  153. @@ -2144,9 +2144,7 @@
  154. charmap.encoding = FT_ENCODING_NONE; /* will be filled later */
  155. offset = TT_NEXT_ULONG( p );
  156. - if ( offset &&
  157. - table + offset + 2 < limit &&
  158. - table + offset >= table )
  159. + if ( offset && offset <= face->cmap_size -2 )
  160. {
  161. FT_Byte* cmap = table + offset;
  162. volatile FT_UInt format = TT_PEEK_USHORT( cmap );