You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2015/11/16 19:57:14 UTC
svn commit: r1714651 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Author: tilman
Date: Mon Nov 16 18:57:14 2015
New Revision: 1714651
URL: http://svn.apache.org/viewvc?rev=1714651&view=rev
Log:
PDFBOX-3112: adjust impossible /Length1 values; improve javadoc
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java?rev=1714651&r1=1714650&r2=1714651&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java Mon Nov 16 18:57:14 2015
@@ -158,6 +158,7 @@ public class PDType1Font extends PDSimpl
*
* @param doc PDF document to write to
* @param pfbIn PFB file stream
+ * @param encoding
* @throws IOException
*/
public PDType1Font(PDDocument doc, InputStream pfbIn, Encoding encoding) throws IOException
@@ -175,7 +176,9 @@ public class PDType1Font extends PDSimpl
/**
* Creates a Type 1 font from a Font dictionary in a PDF.
*
- * @param fontDictionary font dictionary
+ * @param fontDictionary font dictionary.
+ * @throws IOException if there was an error initializing the font.
+ * @throws IllegalArgumentException if /FontFile3 was used.
*/
public PDType1Font(COSDictionary fontDictionary) throws IOException
{
@@ -274,6 +277,10 @@ public class PDType1Font extends PDSimpl
{
// scan backwards from the end of the first segment to find 'exec'
int offset = Math.max(0, length1 - 4);
+ if (offset <= 0 || offset > bytes.length - 4)
+ {
+ offset = bytes.length - 4;
+ }
while (offset > 0)
{
if (bytes[offset + 0] == 'e' &&
@@ -294,7 +301,10 @@ public class PDType1Font extends PDSimpl
if (length1 - offset != 0 && offset > 0)
{
- LOG.warn("Ignored invalid Length1 for Type 1 font " + getName());
+ if (LOG.isWarnEnabled())
+ {
+ LOG.warn("Ignored invalid Length1 " + length1 + " for Type 1 font " + getName());
+ }
return offset;
}