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
gd2: handle corrupt images better (CVE-2016-3074)
Make sure we do some range checking on corrupted chunks. Thanks to Hans Jerry Illikainen <hji@dyntopia.com> for indepth report and reproducer information. Made for easy test case writing :).
- Loading branch information
Showing
5 changed files
with
30 additions
and
1 deletion.
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,25 @@ | ||
| /* Just try to read the invalid gd2 image & not crash. */ | ||
| #include "gd.h" | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include "gdtest.h" | ||
|
|
||
| int main() | ||
| { | ||
| gdImagePtr im; | ||
| FILE *fp; | ||
| char path[1024]; | ||
|
|
||
| /* Read the corrupt image. */ | ||
| sprintf(path, "%s/gd2/invalid_neg_size.gd2", GDTEST_TOP_DIR); | ||
| fp = fopen(path, "rb"); | ||
| if (!fp) { | ||
| printf("failed, cannot open file\n"); | ||
| return 1; | ||
| } | ||
| im = gdImageCreateFromGd2(fp); | ||
| fclose(fp); | ||
|
|
||
| /* Should have failed & rejected it. */ | ||
| return im == NULL ? 0 : 1; | ||
| } |
Binary file not shown.