Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tx] report error on short CFF2 charstring #903

Merged
merged 3 commits into from
Aug 15, 2019

Conversation

cjchapman
Copy link
Contributor

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 an endchar 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 the tx -cff and tx -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 of bug356.otf to bug895.otf in the bad folder. I then hand hex-edited the bug356.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.)

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 an `endchar` 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 the `tx -cff` and `tx -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 of `bug356.otf` to `bug895.otf` in the `bad` folder. I then hand hex-edited the `bug356.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.)
@cjchapman cjchapman force-pushed the cjc-tx-handle-short-charstrings branch from 52376e0 to 2103bcb Compare August 14, 2019 17:50
c/public/lib/api/tx_shared.h Outdated Show resolved Hide resolved
c/public/lib/source/cffread/cffread.c Show resolved Hide resolved
(I used braces in one file and not the other to match the style of other macros in those files.)
@cjchapman cjchapman merged commit 2f0f7ca into develop Aug 15, 2019
@cjchapman cjchapman deleted the cjc-tx-handle-short-charstrings branch August 15, 2019 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug356.otf is rejected by OTS/can’t be dumped by FontTools
2 participants