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

Fix malloc in _imagingft.c:font_setvaraxes #6690

Merged
merged 1 commit into from Oct 27, 2022
Merged

Fix malloc in _imagingft.c:font_setvaraxes #6690

merged 1 commit into from Oct 27, 2022

Conversation

cgohlke
Copy link
Contributor

@cgohlke cgohlke commented Oct 26, 2022

Fixes possible buffer overflow.

@cgohlke
Copy link
Contributor Author

cgohlke commented Oct 27, 2022

As expected, it's easy to crash the current implementation with any input exceeding 4*sizeof(long), e.g.:

Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import ImageFont
>>> f = ImageFont.truetype('cmr10.ttf')
>>> f
<PIL.ImageFont.FreeTypeFont object at 0x0000028609BF0510>
>>> f.set_variation_by_axes([0] * 5)
Windows fatal exception: access violation

Current thread 0x0000126c (most recent call first):
  File "X:\Python311\Lib\site-packages\PIL\ImageFont.py", line 828 in set_variation_by_axes
  File "<stdin>", line 1 in <module>

@hugovk hugovk added this to the 9.3.0 milestone Oct 27, 2022
@hugovk hugovk merged commit 3cd8eae into python-pillow:main Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants