Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix #340: System frozen
gdImageCreate() doesn't check for oversized images and as such is prone to DoS vulnerabilities. We fix that by applying the same overflow check that is already in place for gdImageCreateTrueColor(). CVE-2016-9317
- Loading branch information
Showing
7 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /bug00340 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| SET(TESTS_FILES | ||
| bug00340 | ||
| ) | ||
|
|
||
| ADD_GD_TESTS() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| libgd_test_programs += \ | ||
| gdimagecreate/bug00340 | ||
|
|
||
| EXTRA_DIST += \ | ||
| gdimagecreate/CMakeLists.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * Regression test for <https://github.com/libgd/libgd/issues/340> | ||
| * | ||
| * We're testing that trying to create an oversized image fails early, | ||
| * triggering an appropriate warning. | ||
| */ | ||
|
|
||
|
|
||
| #include <string.h> | ||
| #include "gd.h" | ||
| #include "gd_errors.h" | ||
| #include "gdtest.h" | ||
|
|
||
|
|
||
| #define MSG "product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n" | ||
|
|
||
|
|
||
| void error_handler(int priority, const char *format, ...) | ||
| { | ||
| gdTestAssert(priority == GD_WARNING); | ||
| gdTestAssert(!strcmp(format, MSG)); | ||
| } | ||
|
|
||
|
|
||
| int main() | ||
| { | ||
| gdImagePtr im; | ||
|
|
||
| im = gdImageCreate(64970, 65111); | ||
| gdTestAssert(im == NULL); | ||
|
|
||
| return gdNumFailures(); | ||
| } |