| Summary: | oob in SDL_InvalidateMap | ||
|---|---|---|---|
| Product: | SDL_image | Reporter: | pwd <teamseri0us360> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | castro8583bennett, fieldengineer59, hle, icculus |
| Version: | unspecified | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| URL: | https://www.fieldengineer.com/blogs/how-field-engineer-helps-california-businesses-cut-costs-by-60 | ||
| Attachments: |
poc
[PATCH] pcx: cast size and check calloc return value |
||
|
Description
pwd
2019-05-05 03:04:23 UTC
Created attachment 3799 [details]
[PATCH] pcx: cast size and check calloc return value
Patch in attachment.
summary:
bpl is stored as a signed integer. If it happens to be negative, calloc
will be called with surface->pitch (since bpl < surface->pitch). Later we
call SDL_RWread(src, buf, bpl, 1). bpl is thus cast to size_t (becoming a
very large positive value), leading to obvious oob write.
We should fail early in this case. It doesn't make sense to continue
processing such files with corrupted bpl.
+ (size_t) cast bpl in SDL_max so that it is preferred over surface->pitch
if it is negative
+ check calloc return value to catch allocation failures
+ make sure we don't free unallocated buf in done section
This is a bug in SDL_Image. This issue was assigned CVE-2019-12222. (In reply to Hugo Lefeuvre from comment #1) > + make sure we don't free unallocated buf in done section Minor nitpick: + if (buf) { + SDL_free(buf); + } There's no need to check if buf != NULL here; SDL_free correctly ignores NULLs. Other than that, this patch looks good to me. --ryan. > Minor nitpick:
>
> + if (buf) {
> + SDL_free(buf);
> + }
>
> There's no need to check if buf != NULL here; SDL_free correctly ignores
> NULLs.
>
> Other than that, this patch looks good to me.
Thanks for the review. Should I submit an updated version?
This is fixed, thanks! May i know the solution? Castro B, https://sparpedia.ch how does the gig economy work Considered a haven for tech companies, entrepreneurs and savvy investors, California is home to numerous Fortune 500 companies. What’s more – it’s the most popular state for companies to base their headquarters. Currently, the headquarters of 20% of public companies in the US are in California, and it’s a trend which doesn’t show any signs of slowing down. https://www.fieldengineer.com/blogs/how-field-engineer-helps-california-businesses-cut-costs-by-60 |