Permalink
Show file tree
Hide file tree
1 comment
on commit
sign in to comment.
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 #354: Signed Integer Overflow gd_io.c
GD2 stores the number of horizontal and vertical chunks as words (i.e. 2 byte unsigned). These values are multiplied and assigned to an int when reading the image, what can cause integer overflows. We have to avoid that, and also make sure that either chunk count is actually greater than zero. If illegal chunk counts are detected, we bail out from reading the image.
- Loading branch information
Showing
7 changed files
with
41 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| /bug_289 | ||
| /bug00309 | ||
| /bug00354 | ||
| /gd2_empty_file | ||
| /gd2_im2im | ||
| /gd2_null | ||
|
|
||
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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| LIST(APPEND TESTS_FILES | ||
| bug_289 | ||
| bug00309 | ||
| bug00354 | ||
| gd2_empty_file | ||
| gd2_im2im | ||
| gd2_null | ||
|
|
||
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,32 @@ | ||
| /** | ||
| * We're testing GD2 image files which report illegal chunk counts. These should | ||
| * not cause integer overflows or other issues, but instead simply fail to be | ||
| * loaded. | ||
| * | ||
| * See also <https://github.com/libgd/libgd/issues/354>. | ||
| */ | ||
|
|
||
|
|
||
| #include "gd.h" | ||
| #include "gdtest.h" | ||
|
|
||
|
|
||
| int main() | ||
| { | ||
| gdImagePtr im; | ||
| FILE *fp; | ||
|
|
||
| fp = gdTestFileOpen2("gd2", "bug00354a.gd2"); | ||
| gdTestAssert(fp != NULL); | ||
| im = gdImageCreateFromGd2(fp); | ||
| gdTestAssert(im == NULL); | ||
| fclose(fp); | ||
|
|
||
| fp = gdTestFileOpen2("gd2", "bug00354b.gd2"); | ||
| gdTestAssert(fp != NULL); | ||
| im = gdImageCreateFromGd2(fp); | ||
| gdTestAssert(im == NULL); | ||
| fclose(fp); | ||
|
|
||
| return gdNumFailures(); | ||
| } |
Binary file not shown.
Binary file not shown.
69d2fd2There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is CVE-2016-10168