Gábor Stefanik created PDFBOX-5123:
--------------------------------------
Summary: OS2WindowMetricsTable "version" variable confusion causes
EOFException on reading nonexistent codePageRange
Key: PDFBOX-5123
URL: https://issues.apache.org/jira/browse/PDFBOX-5123
Project: PDFBox
Issue Type: Bug
Components: FontBox
Affects Versions: 2.0.22
Reporter: Gábor Stefanik
Attachments:
SZAMLA-20190417-20190012706-ININET-BroadBitHungary-11646-HUF.pdf
OS2WindowMetricsTable contains the following code:
{code:java}
/**
* This will read the required data from the stream.
*
* @param ttf The font that is being read.
* @param data The stream to read the data from.
* @throws IOException If there is an error reading the data.
*/
@Override
void read(TrueTypeFont ttf, TTFDataStream data) throws IOException
{
version = data.readUnsignedShort();
averageCharWidth = data.readSignedShort();
weightClass = data.readUnsignedShort();
widthClass = data.readUnsignedShort();
fsType = data.readSignedShort();
subscriptXSize = data.readSignedShort();
subscriptYSize = data.readSignedShort();
subscriptXOffset = data.readSignedShort();
subscriptYOffset = data.readSignedShort();
superscriptXSize = data.readSignedShort();
superscriptYSize = data.readSignedShort();
superscriptXOffset = data.readSignedShort();
superscriptYOffset = data.readSignedShort();
strikeoutSize = data.readSignedShort();
strikeoutPosition = data.readSignedShort();
familyClass = data.readSignedShort();
panose = data.read(10);
unicodeRange1 = data.readUnsignedInt();
unicodeRange2 = data.readUnsignedInt();
unicodeRange3 = data.readUnsignedInt();
unicodeRange4 = data.readUnsignedInt();
achVendId = data.readString(4);
fsSelection = data.readUnsignedShort();
firstCharIndex = data.readUnsignedShort();
lastCharIndex = data.readUnsignedShort();
typoAscender = data.readSignedShort();
typoDescender = data.readSignedShort();
typoLineGap = data.readSignedShort();
winAscent = data.readUnsignedShort();
winDescent = data.readUnsignedShort();
if (version >= 1)
{
codePageRange1 = data.readUnsignedInt();
codePageRange2 = data.readUnsignedInt();
}
if (version >= 1.2)
{
sxHeight = data.readSignedShort();
sCapHeight = data.readSignedShort();
usDefaultChar = data.readUnsignedShort();
usBreakChar = data.readUnsignedShort();
usMaxContext = data.readUnsignedShort();
}
initialized = true;
}
{code}
Here, "version" is an integer, local to this class, which is supposed to
represent the version number of the window metrics table itself (not the whole
font). In the case of the first font in the attached PDF, this has a value of
3. (Note that this PDF is itself buggy, declaring a table version of 3 for
what's clearly a version 0 table, but that will be a separate issue.)
However, at the end of the code, this is seemingly confused with the font
version number, and is compared against the float value 1.2. Java allows
comparison between int and float, so no compile-time error or warning is raised.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]