[bdf] Fix underflow of an unsigned value. bdflib.c:1562 could be reached with `font->glyphs_used == 0'. That caused an underflow of the unsigned value which results in undefined behaviour. * src/bdf/bdflib.c (src/bdf/bdflib.c): Bail out earlier than before if the `ENCODING' keyword cannot be found.
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
diff --git a/ChangeLog b/ChangeLog
index 05b1772..9bee9e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2018-06-17 Armin Hasitzka <prince.cherusker@gmail.com>
+
+ [bdf] Fix underflow of an unsigned value.
+
+ bdflib.c:1562 could be reached with `font->glyphs_used == 0'. That
+ caused an underflow of the unsigned value which results in undefined
+ behaviour.
+
+ * src/bdf/bdflib.c (src/bdf/bdflib.c): Bail out earlier than before
+ if the `ENCODING' keyword cannot be found.
+
2018-06-17 Werner Lemberg <wl@gnu.org>
[base] Add tracing for `FT_Bitmap_Blend'.
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 1b8d460..5c09591 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1556,6 +1556,9 @@
goto Exit;
}
+ if ( !( p->flags & BDF_ENCODING_ ) )
+ goto Missing_Encoding;
+
/* Point at the glyph being constructed. */
if ( p->glyph_enc == -1 )
glyph = font->unencoded + ( font->unencoded_used - 1 );
@@ -1626,9 +1629,6 @@
/* Expect the SWIDTH (scalable width) field next. */
if ( _bdf_strncmp( line, "SWIDTH", 6 ) == 0 )
{
- if ( !( p->flags & BDF_ENCODING_ ) )
- goto Missing_Encoding;
-
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -1642,9 +1642,6 @@
/* Expect the DWIDTH (scalable width) field next. */
if ( _bdf_strncmp( line, "DWIDTH", 6 ) == 0 )
{
- if ( !( p->flags & BDF_ENCODING_ ) )
- goto Missing_Encoding;
-
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -1670,9 +1667,6 @@
/* Expect the BBX field next. */
if ( _bdf_strncmp( line, "BBX", 3 ) == 0 )
{
- if ( !( p->flags & BDF_ENCODING_ ) )
- goto Missing_Encoding;
-
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;