Skip to content

Commit

Permalink
[CFF2] Lift uint16 VariationStore.length limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Oct 27, 2024
1 parent 5daecc9 commit 3b6f9b5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -588,19 +588,25 @@ bool ParsePrivateDictData(
}

bool ParseVariationStore(ots::OpenTypeCFF& out_cff, ots::Buffer& table) {
uint16_t length;
uint16_t encoded_length;

if (!table.ReadU16(&length)) {
if (!table.ReadU16(&encoded_length)) {
return OTS_FAILURE();
}

unsigned length = encoded_length;

// Empty VariationStore is allowed.
if (!length) {
return true;
}

if (length > table.remaining()) {
return OTS_FAILURE();
if (length != 65535) {
if (length > table.remaining()) {
return OTS_FAILURE();
}
} else {
length = table.remaining();
}

if (!ParseItemVariationStore(out_cff.GetFont(),
Expand Down

0 comments on commit 3b6f9b5

Please sign in to comment.