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

[makeotfexe] increase uvName string length limit #1311

Merged
merged 4 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion c/makeotf/makeotf_lib/api/hotconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This software is licensed as OpenSource, under the Apache License, Version 2.0.
extern "C" {
#endif

#define HOT_VERSION 0x010075 /* Library version (1.0.117) */
#define HOT_VERSION 0x010076 /* Library version (1.0.118) */
/* Major, minor, build = (HOT_VERSION >> 16) & 0xff, (HOT_VERSION >> 8) & 0xff, HOT_VERSION & 0xff) */
/* Warning: this string is now part of heuristic used by CoolType to identify the
first round of CoolType fonts which had the backtrack sequence of a chaining
Expand Down
8 changes: 7 additions & 1 deletion c/makeotf/source/cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ extern jmp_buf mark;
#define WINDOWS_DECORATIVE (5 << 4)
#define MAX_CHAR_NAME_LEN 63 /* Max charname len (inc '\0') */
#define MAX_FINAL_CHAR_NAME_LEN 63 /* Max charname len (inc '\0') */
#define MAX_UV_CHAR_NAME_LEN 2047 /* length of entire alias string (column) */

#ifdef _MSC_VER /* defined by Microsoft Compiler */
#include <io.h>
Expand Down Expand Up @@ -900,6 +901,11 @@ enum {
static char *gnameScan(cbCtx h, char *p, unsigned char *action, unsigned char *next, int nameType) {
char *start = p;
int state = 0;
int nameLimit = MAX_CHAR_NAME_LEN;

if (nameType == uvName) {
nameLimit = MAX_UV_CHAR_NAME_LEN;
}

for (;;) {
int actn;
Expand Down Expand Up @@ -934,7 +940,7 @@ static char *gnameScan(cbCtx h, char *p, unsigned char *action, unsigned char *n
return NULL;
}
if (actn & Q_) {
if (p - start > MAX_CHAR_NAME_LEN) {
if (p - start > nameLimit) {
return NULL; /* Maximum glyph name length exceeded */
}
return p;
Expand Down
2 changes: 1 addition & 1 deletion c/makeotf/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

jmp_buf mark;

#define MAKEOTF_VERSION "2.5.65602"
#define MAKEOTF_VERSION "2.5.65603"
/* Warning: this string is now part of heuristic used by CoolType to identify the
first round of CoolType fonts which had the backtrack sequence of a chaining
contextual substitution ordered incorrectly. Fonts with the old ordering MUST match
Expand Down
2 changes: 1 addition & 1 deletion python/afdko/makeotf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"""

__version__ = """\
makeotf.py v2.8.4 November 9 2020
makeotf.py v2.8.5 February 22 2021
"""

__methods__ = """
Expand Down
2 changes: 2 additions & 0 deletions tests/makeotfexe_data/input/bug1310/longGnameGOADB.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.notdef .notdef
a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaax uni0061
2 changes: 2 additions & 0 deletions tests/makeotfexe_data/input/bug1310/longUVGOADB.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.notdef .notdef
a a uni0061,uniF020,uniF021,uniF022,uniF023,uniF024,uniF025,uniF026,uniF027,uniF028,uniF029,uniF02A,uniF02B,uniF02C,uniF02D,uniF02E,uniF02F,uniF030,uniF031,uniF032,uniF033,uniF034,uniF035,uniF036,uniF037,uniF038,uniF039,uniF03A,uniF03B,uniF03C,uniF03D,uniF03E,uniF03F,uniF040,uniF041,uniF042,uniF043,uniF044,uniF045,uniF046,uniF047,uniF048,uniF049,uniF04A,uniF04B,uniF04C,uniF04D,uniF04E,uniF04F,uniF050,uniF051,uniF052,uniF053,uniF054,uniF055,uniF056,uniF057,uniF058,uniF059,uniF05A,uniF05B,uniF05C,uniF05D,uniF05E,uniF05F,uniF060,uniF061,uniF062,uniF063,uniF064,uniF065,uniF066,uniF067,uniF068,uniF069,uniF06A,uniF06B,uniF06C,uniF06D,uniF06E,uniF06F,uniF070,uniF071,uniF072,uniF073,uniF074,uniF075,uniF076,uniF077,uniF078,uniF079,uniF07A,uniF07B,uniF07C,uniF07D,uniF07E,uniF07F
28 changes: 28 additions & 0 deletions tests/makeotfexe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,3 +706,31 @@ def test_negative_internal_leading_bug1227():
output = f.read()
assert (b'[WARNING] <SourceSerifPro-Regular> Negative internal leading: '
b'win.ascent + win.descent < unitsPerEm') in output


@pytest.mark.parametrize(
'goadb_filename, expected',
[('bug1310/longUVGOADB.txt', False),
('bug1310/longGnameGOADB.txt', True)])
def test_glyph_alias_name_limits(goadb_filename, expected):
"""
- 'longUVGOADB' has a 3rd column (UV names) with length > 63. This should
is expected to be allowed (up to MAX_UV_CHAR_NAME_LEN in cb.c)
- 'longGnameGOADB' has 2nd column (glyph name) with a length > 63. This
is expected to raise a warning.
"""
input_filename = "font.pfa"
actual_path = get_temp_file_path()

cmd = CMD + ['-s', '-e', '-o',
'r',
'f', f'_{get_input_path(input_filename)}',
'o', f'_{actual_path}',
'gf', f'_{get_input_path(goadb_filename)}']

stderr_path = runner(cmd)

with open(stderr_path, 'rb') as f:
output = f.read()

assert (b'(record skipped)(gnameError)' in output) is expected