Simon Steiner created PDFBOX-6352:
-------------------------------------
Summary: TrueType 'name' table records can all point at one 64 KB
string, so a small font allocates gigabytes of heap
Key: PDFBOX-6352
URL: https://issues.apache.org/jira/browse/PDFBOX-6352
Project: PDFBox
Issue Type: Bug
Reporter: Simon Steiner
FontBox's NamingTable.read parses a TrueType/OpenType font's 'name' table. It
reads up to 65,535 name records from the font. For each record it seeks to the
record's stringOffset, decodes stringLength bytes (up to 65,535) into a new
String, and keeps it in nameRecords for as long as the font object lives.
Nothing checks offsets and lengths against the table length, nothing stops
records from overlapping, and nothing caps the total decoded size. So every
record can point at the same 64 KB of bytes, and each one is decoded again into
its own string. A font of under 1 MB, which compresses to about a kilobyte
inside a PDF, ends up holding 4-8 GB of strings. PDFBox parses embedded
TrueType and OpenType fonts this way while it loads fonts for text extraction
and rendering.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]