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

Avoid various overflows in CFF #1196

Merged
merged 2 commits into from
Oct 21, 2024
Merged

Avoid various overflows in CFF #1196

merged 2 commits into from
Oct 21, 2024

Conversation

dfrg
Copy link
Member

@dfrg dfrg commented Oct 21, 2024

Add targeted wrapping_add and wrapping_sub calls to avoid panics on arithmetic overflows for the specific case in #1193

Add targeted `wrapping_add` and `wrapping_sub` calls to avoid panics on arithmetic overflows for the specific case in #1193
Copy link
Contributor

@drott drott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes, comments below:

@@ -224,6 +224,12 @@ impl Stack {
} else {
Fixed::from_i32(*value)
};
// See <https://github.com/googlefonts/fontations/issues/1193>
// The "DIN Alternate" font contains incorrect blue values
// that cause an overflow in this computation. FreeType does
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Would you have a link to the equivalent logic in FreeType similar to this delta accumulation here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The equivalent logic is here: https://gitlab.freedesktop.org/freetype/freetype/-/blob/57617782464411201ce7bbc93b086c1b4d7d84a5/src/cff/cffparse.c#L1431 along with the "fixed" case below. I'll add this link to the code.

skrifa/src/outline/cff/hint.rs Show resolved Hide resolved
skrifa/src/outline/cff/hint.rs Show resolved Hide resolved
Copy link
Contributor

@drott drott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes.

@drott
Copy link
Contributor

drott commented Oct 21, 2024

Confirmed locally to enable the display of the DIN font using Fontations in Chromium.

@dfrg dfrg merged commit 9ac54bd into main Oct 21, 2024
10 checks passed
@dfrg dfrg deleted the cff-overflows branch October 21, 2024 14:20
dfrg added a commit that referenced this pull request Oct 22, 2024
Add targeted `wrapping_add` and `wrapping_sub` calls to avoid panics on arithmetic overflows for the specific case in #1193
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.

2 participants