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 2021/11/24 16:48:06 UTC
svn commit: r1895301 - /pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java
Author: tilman
Date: Wed Nov 24 16:48:06 2021
New Revision: 1895301
URL: http://svn.apache.org/viewvc?rev=1895301&view=rev
Log:
PDFBOX-5285: skip tables that will bring an EOF
Modified:
pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java
Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java?rev=1895301&r1=1895300&r2=1895301&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java Wed Nov 24 16:48:06 2021
@@ -19,6 +19,8 @@ package org.apache.fontbox.ttf;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* TrueType font file parser.
@@ -27,6 +29,8 @@ import java.io.InputStream;
*/
public class TTFParser
{
+ private static final Log LOG = LogFactory.getLog(TTFParser.class);
+
private boolean isEmbedded = false;
private boolean parseOnDemandOnly = false;
@@ -141,7 +145,18 @@ public class TTFParser
// skip tables with zero length
if (table != null)
{
- font.addTable(table);
+ if (table.getOffset() + table.getLength() > font.getOriginalDataSize())
+ {
+ // PDFBOX-5285 if we're lucky, this is an "unimportant" table, e.g. vmtx
+ LOG.warn("Skip table '" + table.getTag() +
+ "' which goes past the file size; offset: " + table.getOffset() +
+ ", size: " + table.getLength() +
+ ", font size: " + font.getOriginalDataSize());
+ }
+ else
+ {
+ font.addTable(table);
+ }
}
}
// parse tables if wanted