DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40387>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40387

           Summary: PFMFile.load() crashes if a font has a name longer than
                    16 characters and also if parsing pfm files larger than
                    2048 bytes
           Product: Fop
           Version: 1.0dev
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: ErrorMessage, PatchAvailable
          Severity: normal
          Priority: P2
         Component: general
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: [EMAIL PROTECTED]


I think the summary is clear enough.
To solve the issues: 
1.) increase mark parameter of inStream.
2.) set a correct buffersize when convert it to a BufferdInputStream


Here is the patch that is API compatible with older versions.

Index: PFMFile.java
===================================================================
--- PFMFile.java        (revision 439270)
+++ PFMFile.java        (working copy)
@@ -70,18 +70,37 @@
     protected Log log = LogFactory.getLog(PFMFile.class);
 
     /**
+     * Parses a PFM file.
+     * It is the same as load(inStream, 0);
+     *
+     * @param  inStream The stream from which to read the PFM file.
+     * @throws IOException In case of an I/O problem
+     */
+    public void load(InputStream inStream) throws IOException {
+        load(inStream, 0);
+    }
+
+    /**
      * Parses a PFM file
      *
      * @param  inStream The stream from which to read the PFM file.
+     * @param  bufferSize If inStream doesn't support marks and it is going to
be buffered, the size the bufferd stream must have.
+     * Will be ignored if inStream supports marks. Should equal the full size
of inStream.
      * @throws IOException In case of an I/O problem
      */
-    public void load(InputStream inStream) throws IOException {
+    public void load(InputStream inStream, int bufferSize) throws IOException {
         InputStream bufin = inStream;
         if (!bufin.markSupported()) {
-            bufin = new BufferedInputStream(bufin);
+            if (bufferSize > 0)
+                bufin = new BufferedInputStream(bufin, bufferSize);
+            else
+                bufin = new BufferedInputStream(bufin);
+
         }
         PFMInputStream in = new PFMInputStream(bufin);
-        bufin.mark(16);
+// increased buff.mark() four times to avoid errors when reading fontnames
larger than 16 characters.
+//        bufin.mark(16);
+        bufin.mark(64);
         short sh1 = in.readByte();
         short sh2 = in.readByte();
         if (sh1 == 128 && sh2 == 1) {

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Reply via email to