]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4989/3: Add a guard against invalid Type 1 (PFB) font
authorMasamichi Hosoda <trueroad@trueroad.jp>
Thu, 27 Oct 2016 14:57:43 +0000 (23:57 +0900)
committerMasamichi Hosoda <trueroad@trueroad.jp>
Thu, 3 Nov 2016 21:52:50 +0000 (06:52 +0900)
This commit makes LilyPond can detect invalid Type1 (PFB) font.

lily/pfb.cc

index 4f371c6c9446af214fb7752103d37270f181cbce..101f4f0fc68a7c947470b226b0fcb903b6395046 100644 (file)
@@ -24,6 +24,7 @@
 #include <sstream>
 using namespace std;
 
+#include "international.hh"
 #include "program-option.hh"
 #include "source-file.hh"
 #include "memory-stream.hh"
@@ -40,7 +41,10 @@ pfb2pfa (const vector<char> &pfb)
   while (p < pfb.end ())
     {
       if (static_cast<Byte>(*p++) != 128)
-        break;
+        {
+          error (_ ("Segment header of the Type 1 (PFB) font is broken."));
+          break;
+        }
 
       Byte type = static_cast<Byte>(*p++);
       if (type == 3)
@@ -50,6 +54,11 @@ pfb2pfa (const vector<char> &pfb)
       seglen |= (static_cast<Byte>(*p++) << 8);
       seglen |= (static_cast<Byte>(*p++) << 16);
       seglen |= (static_cast<Byte>(*p++) << 24);
+      if ((p + seglen) > pfb.end ())
+        {
+          error (_ ("Segment length of the Type 1 (PFB) font is too long."));
+          break;
+        }
 
       if (type == 1)
         {
@@ -72,6 +81,11 @@ pfb2pfa (const vector<char> &pfb)
           string str = ss.str ();
           copy (str.begin (), str.end (), back_inserter (out));
         }
+      else
+        {
+          error (_ ("Segment type of the Type 1 (PFB) font is unknown."));
+          break;
+        }
     }
 
   return out;