Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add protection against out-of-bounds read in ttconv#20629

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

sauerburger
Copy link
Member

@sauerburgersauerburger commentedJul 11, 2021
edited
Loading

This PR addresses#20628.

PR Summary

The member variablefont->numTables indicates the number of tables stored in the directory table. The size of the memory allocated for the directory tableis derived from this variable. This PR adds a safe-guard inttfont_sfnts() to preventptr to move beyond the end of the table and thus prevent read-access beyond the memory allocated forfont->offset_table.

See#20628

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • [N/A] New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • [N/A] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link
Member

@jkseppanjkseppan left a comment

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor

@aitikguptaaitikgupta left a comment
edited
Loading

Choose a reason for hiding this comment

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

Awesome! 🎉

Can we introduce a test (likely the code sample in#20628 (comment)) here?
(that raises another bug, but is there a way we can triggeronly this out-of-bounds error?)

Or.. testing ttconv snippets are out of scope of Matplotlib?

@QuLogicQuLogic added this to thev3.4.3 milestoneJul 13, 2021
@QuLogicQuLogic linked an issueJul 13, 2021 that may beclosed by this pull request
@QuLogicQuLogic mentioned this pull requestJul 13, 2021
4 tasks
@QuLogic
Copy link
Member

You should try to use thelinking keywords when you know this fixes the issue.

Since I've merged the other PR, please add a test here.

@sauerburger
Copy link
MemberAuthor

You should try to use thelinking keywords when you know this fixes the issue.

Sorry, about that. I've updated the other open PRs.

Since I've merged the other PR, please add a test here.

Thanks! I'll rebase the PR.

It would be super difficult to test the initial issue, i.e. a test that would fail on an out-of-bounds read. The table search exits in most cases by chance. At some point, random bytes interpreted as a table name make the algorithm think it is already beyond the sought for entry. To test this manually, I ranvalgrind withgrep 'pprdrv_tt.cpp:7' (since I couldn't get the Python suppression to work) and made sure that this problematic memory access disappears.

I can, however, add a test, like the example, to make sure that the output is valid (but this test would succeed in ~99% of the cases even without this PR).

@QuLogic
Copy link
Member

Yes, but it would at least check that the change from the other PR wouldn't break. We'll have to live with the possibility of a flaky error if this one resurfaces, but that's unlikely anyway.

I was able to replicate this issue in valgrind, so at least that's known to be fixed.

This commit adds to counter to track how many tables are read from the tabledirectory and stops the search for further tables early if the total number oftables has been reached.
The new test case checks that Type 42 fonts without the prep table (here stix),are properly embedded. The test succeeds if the embedded font contains valuesfor searchRange, entrySelector, rangeShift; and no erroneous out-of-bounds readoccurs while searching for the missing prep table.
@sauerburgersauerburgerforce-pushed thefix-out-of-bounds-read-ttconv branch from1073013 todeefcbaCompareJuly 13, 2021 13:06
@jkseppanjkseppan merged commitdba02be intomatplotlib:masterJul 13, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestJul 13, 2021
QuLogic added a commit that referenced this pull requestJul 13, 2021
…629-on-v3.4.xBackport PR#20629 on branch v3.4.x (Add protection against out-of-bounds read in ttconv)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jkseppanjkseppanjkseppan approved these changes

@QuLogicQuLogicQuLogic approved these changes

@aitikguptaaitikguptaaitikgupta approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.4.3
Development

Successfully merging this pull request may close these issues.

Out-of-bounds read leads to crash or broken TrueType fonts
4 participants
@sauerburger@QuLogic@jkseppan@aitikgupta

[8]ページ先頭

©2009-2025 Movatter.jp