t1lib-5.1.2-CVE-2011-1552_1553_1554.patch 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. Author: Jaroslav Škarvada <jskarvad@redhat.com>
  2. Description: Fix more crashes on oversized fonts
  3. Bug-Redhat: http://bugzilla.redhat.com/show_bug.cgi?id=692909
  4. Index: b/lib/type1/lines.c
  5. ===================================================================
  6. --- a/lib/type1/lines.c 2007-12-23 09:49:42.000000000 -0600
  7. +++ b/lib/type1/lines.c 2012-01-17 14:15:08.000000000 -0600
  8. @@ -67,6 +67,10 @@
  9. None.
  10. */
  11. +#define BITS (sizeof(LONG)*8)
  12. +#define HIGHTEST(p) (((p)>>(BITS-2)) != 0) /* includes sign bit */
  13. +#define TOOBIG(xy) ((xy < 0) ? HIGHTEST(-xy) : HIGHTEST(xy))
  14. +
  15. /*
  16. :h2.StepLine() - Produces Run Ends for a Line After Checks
  17. @@ -84,6 +88,9 @@
  18. IfTrace4((LineDebug > 0), ".....StepLine: (%d,%d) to (%d,%d)\n",
  19. x1, y1, x2, y2);
  20. + if ( TOOBIG(x1) || TOOBIG(x2) || TOOBIG(y1) || TOOBIG(y2))
  21. + abort("Lines this big not supported", 49);
  22. +
  23. dy = y2 - y1;
  24. /*
  25. Index: b/lib/type1/objects.c
  26. ===================================================================
  27. --- a/lib/type1/objects.c 2007-12-23 09:49:42.000000000 -0600
  28. +++ b/lib/type1/objects.c 2012-01-17 14:15:08.000000000 -0600
  29. @@ -1137,12 +1137,13 @@
  30. "Context: out of them", /* 46 */
  31. "MatrixInvert: can't", /* 47 */
  32. "xiStub called", /* 48 */
  33. - "Illegal access type1 abort() message" /* 49 */
  34. + "Lines this big not supported", /* 49 */
  35. + "Illegal access type1 abort() message" /* 50 */
  36. };
  37. - /* no is valid from 1 to 48 */
  38. - if ( (number<1)||(number>48))
  39. - number=49;
  40. + /* no is valid from 1 to 49 */
  41. + if ( (number<1)||(number>49))
  42. + number=50;
  43. return( err_msgs[number-1]);
  44. }
  45. Index: b/lib/type1/type1.c
  46. ===================================================================
  47. --- a/lib/type1/type1.c 2012-01-17 14:13:28.000000000 -0600
  48. +++ b/lib/type1/type1.c 2012-01-17 14:19:54.000000000 -0600
  49. @@ -1012,6 +1012,7 @@
  50. double nextdtana = 0.0; /* tangent of post-delta against horizontal line */
  51. double nextdtanb = 0.0; /* tangent of post-delta against vertical line */
  52. + if (ppoints == NULL || numppoints < 1) Error0v("FindStems: No previous point!\n");
  53. /* setup default hinted position */
  54. ppoints[numppoints-1].ax = ppoints[numppoints-1].x;
  55. @@ -1289,7 +1290,7 @@
  56. static int DoRead(CodeP)
  57. int *CodeP;
  58. {
  59. - if (strindex >= CharStringP->len) return(FALSE); /* end of string */
  60. + if (!CharStringP || strindex >= CharStringP->len) return(FALSE); /* end of string */
  61. /* We handle the non-documented Adobe convention to use lenIV=-1 to
  62. suppress charstring encryption. */
  63. if (blues->lenIV==-1) {
  64. @@ -1700,7 +1701,7 @@
  65. long pindex = 0;
  66. /* compute hinting for previous segment! */
  67. - if (ppoints == NULL) Error0i("RLineTo: No previous point!\n");
  68. + if (ppoints == NULL || numppoints < 2) Error0i("RLineTo: No previous point!\n");
  69. FindStems( currx, curry, currx-ppoints[numppoints-2].x, curry-ppoints[numppoints-2].y, dx, dy);
  70. /* Allocate a new path point and pre-setup data */
  71. @@ -1729,7 +1730,7 @@
  72. long pindex = 0;
  73. /* compute hinting for previous point! */
  74. - if (ppoints == NULL) Error0i("RRCurveTo: No previous point!\n");
  75. + if (ppoints == NULL || numppoints < 2) Error0i("RRCurveTo: No previous point!\n");
  76. FindStems( currx, curry, currx-ppoints[numppoints-2].x, curry-ppoints[numppoints-2].y, dx1, dy1);
  77. /* Allocate three new path points and pre-setup data */
  78. @@ -1788,7 +1789,9 @@
  79. long tmpind;
  80. double deltax = 0.0;
  81. double deltay = 0.0;
  82. -
  83. +
  84. + if (ppoints == NULL || numppoints < 1) Error0i("DoClosePath: No previous point!");
  85. +
  86. /* If this ClosePath command together with the starting point of this
  87. path completes to a segment aligned to a stem, we would miss
  88. hinting for this point. --> Check and explicitly care for this! */
  89. @@ -1803,6 +1806,7 @@
  90. deltax = ppoints[i].x - ppoints[numppoints-1].x;
  91. deltay = ppoints[i].y - ppoints[numppoints-1].y;
  92. + if (ppoints == NULL || numppoints <= i + 1) Error0i("DoClosePath: No previous point!");
  93. /* save nummppoints and reset to move point */
  94. tmpind = numppoints;
  95. numppoints = i + 1;
  96. @@ -1905,7 +1909,7 @@
  97. FindStems( currx, curry, 0, 0, dx, dy);
  98. }
  99. else {
  100. - if (ppoints == NULL) Error0i("RMoveTo: No previous point!\n");
  101. + if (ppoints == NULL || numppoints < 2) Error0i("RMoveTo: No previous point!\n");
  102. FindStems( currx, curry, ppoints[numppoints-2].x, ppoints[numppoints-2].y, dx, dy);
  103. }
  104. @@ -2155,6 +2159,7 @@
  105. DOUBLE cx, cy;
  106. DOUBLE ex, ey;
  107. + if (ppoints == NULL || numppoints < 8) Error0v("FlxProc: No previous point!");
  108. /* Our PPOINT list now contains 7 moveto commands which
  109. are about to be consumed by the Flex mechanism. --> Remove these
  110. @@ -2324,6 +2329,7 @@
  111. /* Returns currentpoint on stack */
  112. static void FlxProc2()
  113. {
  114. + if (ppoints == NULL || numppoints < 1) Error0v("FlxProc2: No previous point!");
  115. /* Push CurrentPoint on fake PostScript stack */
  116. PSFakePush( ppoints[numppoints-1].x);
  117. PSFakePush( ppoints[numppoints-1].y);