[bdf] Fix Savannah bugs #35599 and #35600. * src/bdf/bdflib.c (ACMSG16): New warning message. (_bdf_parse_glyphs) <_BDF_BITMAP>: Check line length.
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
diff --git a/ChangeLog b/ChangeLog
index cf83e79..98df508 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-02-25 Werner Lemberg <wl@gnu.org>
+
+ [bdf] Fix Savannah bugs #35599 and #35600.
+
+ * src/bdf/bdflib.c (ACMSG16): New warning message.
+ (_bdf_parse_glyphs) <_BDF_BITMAP>: Check line length.
+
2012-02-24 Werner Lemberg <wl@gnu.org>
[bdf] Fix Savannah bugs #35597 and #35598.
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 37ffc1e..f2ca92d 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -188,6 +188,7 @@
#define ACMSG13 "Glyph %ld extra rows removed.\n"
#define ACMSG14 "Glyph %ld extra columns removed.\n"
#define ACMSG15 "Incorrect glyph count: %ld indicated but %ld found.\n"
+#define ACMSG16 "Glyph %ld missing columns padded with zero bits.\n"
/* Error messages. */
#define ERRMSG1 "[line %ld] Missing `%s' line.\n"
@@ -1725,18 +1726,31 @@
for ( i = 0; i < nibbles; i++ )
{
c = line[i];
+ if ( !c )
+ break;
*bp = (FT_Byte)( ( *bp << 4 ) + a2i[c] );
if ( i + 1 < nibbles && ( i & 1 ) )
*++bp = 0;
}
+ /* If any line has not enough columns, */
+ /* indicate they have been padded with zero bits. */
+ if ( i < nibbles &&
+ !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) )
+ {
+ FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG16, glyph->encoding ));
+ p->flags |= _BDF_GLYPH_WIDTH_CHECK;
+ font->modified = 1;
+ }
+
/* Remove possible garbage at the right. */
mask_index = ( glyph->bbx.width * p->font->bpp ) & 7;
if ( glyph->bbx.width )
*bp &= nibble_mask[mask_index];
/* If any line has extra columns, indicate they have been removed. */
- if ( ( line[nibbles] == '0' || a2i[(int)line[nibbles]] != 0 ) &&
+ if ( i == nibbles &&
+ ( line[nibbles] == '0' || a2i[(int)line[nibbles]] != 0 ) &&
!( p->flags & _BDF_GLYPH_WIDTH_CHECK ) )
{
FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG14, glyph->encoding ));