* src/base/ftobjs.c (Mac_Read_POST_Resource): Insert comments and fold too long tracing messages.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
diff --git a/ChangeLog b/ChangeLog
index deac0e7..08f1659 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2014-11-26 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+ * src/base/ftobjs.c (Mac_Read_POST_Resource): Insert comments
+ and fold too long tracing messages.
+
+2014-11-26 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
Fix Savannah bug #43540.
* src/base/ftmac.c (parse_fond): Prevent a buffer overrun
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index dfad24a..4321126 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1580,21 +1580,28 @@
goto Exit;
if ( FT_READ_ULONG( temp ) )
goto Exit;
-#if 0
- FT_TRACE4(( " POST fragment #%d: length=0x%08x\n", i, temp));
+
+ /* FT2 allocator takes signed long buffer length,
+ * too large value causing overflow should be checked
+ */
+ FT_TRACE4(( " POST fragment #%d: length=0x%08x\n",
+ i, temp));
if ( 0x7FFFFFFFUL < temp )
{
error = FT_THROW( Invalid_Offset );
goto Exit;
}
-#endif
pfb_len += temp + 6;
}
- FT_TRACE2(( " total buffer size to concatenate %d POST fragments: 0x%08x\n",
+ FT_TRACE2(( " total buffer size to concatenate %d"
+ " POST fragments: 0x%08x\n",
resource_cnt, pfb_len + 2));
if ( pfb_len + 2 < 6 ) {
+ FT_TRACE2(( " too long fragment length makes"
+ " pfb_len confused: 0x%08x\n",
+ pfb_len ));
error = FT_THROW( Array_Too_Large );
goto Exit;
}
@@ -1619,13 +1626,16 @@
goto Exit2;
if ( FT_READ_ULONG( rlen ) )
goto Exit2;
-#if 0
+
+ /* FT2 allocator takes signed long buffer length,
+ * too large fragment length causing overflow should be checked
+ */
if ( 0x7FFFFFFFUL < rlen )
{
error = FT_THROW( Invalid_Offset );
goto Exit2;
}
-#endif
+
if ( FT_READ_USHORT( flags ) )
goto Exit2;
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
@@ -1650,7 +1660,8 @@
len += rlen;
else
{
- FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer 0x%p + 0x%08x\n", i, pfb_data, pfb_lenpos ));
+ FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer"
+ " 0x%p + 0x%08x\n", i, pfb_data, pfb_lenpos ));
if ( pfb_lenpos + 3 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_lenpos ] = (FT_Byte)( len );
@@ -1661,7 +1672,8 @@
if ( ( flags >> 8 ) == 5 ) /* End of font mark */
break;
- FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer 0x%p + 0x%08x\n", i, pfb_data, pfb_pos ));
+ FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer"
+ " 0x%p + 0x%08x\n", i, pfb_data, pfb_pos ));
if ( pfb_pos + 6 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_pos++] = 0x80;
@@ -1680,7 +1692,8 @@
if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len )
goto Exit2;
- FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer 0x%p + 0x%08x\n", i, rlen, pfb_data, pfb_pos ));
+ FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer"
+ " 0x%p + 0x%08x\n", i, rlen, pfb_data, pfb_pos ));
error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
if ( error )
goto Exit2;
@@ -1709,7 +1722,8 @@
Exit2:
if ( error == FT_ERR( Array_Too_Large ) )
- FT_TRACE2(( " Abort due to too-short buffer to store all POST fragments\n" ));
+ FT_TRACE2(( " Abort due to too-short buffer to store"
+ " all POST fragments\n" ));
else if ( error == FT_ERR( Invalid_Offset ) )
FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" ));
if ( error )