diff -up t1lib-5.1.2/lib/t1lib/parseAFM.c.orig t1lib-5.1.2/lib/t1lib/parseAFM.c
--- t1lib-5.1.2/lib/t1lib/parseAFM.c.orig	2007-12-23 16:49:42.000000000 +0100
+++ t1lib-5.1.2/lib/t1lib/parseAFM.c	2011-05-10 23:59:08.726465425 +0200
@@ -199,7 +199,8 @@ static char *token(stream) 
     idx = 0;
     
     while (ch != EOF && ch != ' ' && ch != CR  && ch != LF &&
-	   ch != CTRL_Z && ch != '\t' && ch != ':' && ch != ';'){
+	   ch != CTRL_Z && ch != '\t' && ch != ':' && ch != ';' &&
+	   idx < (MAX_NAME - 1)){
       ident[idx++] = ch;
       ch = fgetc(stream);
     } /* while */
@@ -235,7 +236,8 @@ static char *linetoken(stream)
     while ((ch = fgetc(stream)) == ' ' || ch == '\t' ); 
     
     idx = 0;
-    while (ch != EOF && ch != CR  && ch != LF && ch != CTRL_Z) 
+    while (ch != EOF && ch != CR  && ch != LF && ch != CTRL_Z &&
+      idx < (MAX_NAME - 1))
     {
         ident[idx++] = ch;
         ch = fgetc(stream);
