[tx] report error on short CFF2 charstring #903
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #895
The
bug356.otf
font originally had only one byte of a two byte integer at the end of the charstring for GID 3.The
tx
code was treating any attempt to read past the end of a CFF2 charstring as equivalent to anendchar
in a CFF charstring, even if it was in the middle of parsing a multi-byte operator or operand. I have changed the code to now report an error if it tries to read past the end of a CFF2 charstring while in the middle of parsing an operator or an operand. I made this fix for both thetx -cff
andtx -dcf
paths through the code. I also made similar fixes in some code for reading dictionaries.I created a new folder
tests/tx_data/input/bad
for known-bad fonts, and copied the bad version ofbug356.otf
tobug895.otf
in thebad
folder. I then hand hex-edited thebug356.otf
font to have a single byte integer at the end of the charstring of GID 3.I also cleaned up several issues reported by Xcode and cppcheck. (Note that I removed some unused code as part of the cleanup.)