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 out of bounds write im->alpha[im->transparent] #785

Merged
merged 2 commits into from Oct 9, 2021

Conversation

bathterror
Copy link
Contributor

Fixes #784

src/gd.c Outdated Show resolved Hide resolved
@vapier vapier merged commit ba14dec into libgd:master Oct 9, 2021
@vapier
Copy link
Member

vapier commented Oct 9, 2021

thx bud

pierrejoye pushed a commit that referenced this pull request Jan 29, 2022
Since #737 gdImageColorTransparent does not correctly handle the case that im->transparent = -1
(which is the initial value and used to indicate no transparent colour has been set).

This leads to undefined behaviour via an out-of-bound write:
im->alpha[im->transparent] = gdAlphaOpaque;
(in practice I assume this merely overwrites an earlier struct member)

This can be triggered via loading a gif through gdImageCreateFromGifPtr

third_party/gd/source/gd.c:922:2: runtime error: index -1 out of bounds for type 'int [256]'
    #0 0x5629c034a839 in gdImageColorTransparent third_party/gd/source/gd.c:922:29
    #1 0x5629c034ebf0 in gdImageCreateFromGifCtx third_party/gd/source/gd_gif_in.c:328:4
    #2 0x5629c034f14f in gdImageCreateFromGifPtr third_party/gd/source/gd_gif_in.c:186:7

Fixes #784.
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.

[regression] undefined behaviour gdImageColorTransparent
2 participants