Skip to content

gdPutBuf return value check #750

Closed
Closed

Description

@meweez

Hi,
Two previous issues #247 and #697, show that a return value check for gdGetBuf is necessary and it can cause read out of bound with a corrupted TGA file.

gdPutBuf is similar to gdGetBuf and it also shows the error condition in its return value.
some usages for gdPutBuf are comparing return values to see any error occurred or not. (in gd_jpeg.c and gd_gd2.c)

but there are some other call sites that do not check the return value and also the passed arguments are tainted and can be corrupted.
this is the list of them:

file function line
gd_webp.c _gdImageWebpCtx 230 link
gd_bmp.c _gdImageBmpCtx 269 link
gd_bmp.c _gdImageBmpCtx 328 link
gd_gif_out.c flush_char 1635 link

so they need to add some condition check for gdPutBuf.

Regards.

Activity

  1. added this to the GD 2.3.3 milestone on Sep 7, 2021
  2. self-assigned this
    on Sep 7, 2021
  3. added 2 commits that reference this issue on Sep 7, 2021
  4. pierrejoye commented on Sep 8, 2021

    @pierrejoye
    Contributor

    Partial fix applied for BMP and WebP. For GIF, a lot of refactoring is needed and I am not sure it is worth it. What do you think?

    We can open a separate issue for GIF as it also requires ABI/API breaks for what I see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions