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

Warn if glyph name too long #235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/post.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

namespace ots {

// "Names must be no longer than 63 characters; some older implementations may
// assume a length limit of 31 characters."
const int MAX_GLYPH_NAME_LENGTH = 63;

bool OpenTypePOST::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);

Expand Down Expand Up @@ -91,6 +95,10 @@ bool OpenTypePOST::Parse(const uint8_t *data, size_t length) {
for (;;) {
if (strings == strings_end) break;
const unsigned string_length = *strings;
if (string_length > MAX_GLYPH_NAME_LENGTH) {
std::string bad_glyph (reinterpret_cast<const char*>(strings + 1), string_length);
Warning("Glyph name %s too long", bad_glyph.c_str());
}
if (strings + 1 + string_length > strings_end) {
return Error("Bad string length %d", string_length);
}
Expand Down