Add regression test for issue #209

Besides the original fix, which catered to the subsequent output, the
potential DOS vulnerability due to a corrupted GD2 image file has been
fixed with c6bb583, and here we make sure that this very image is also
handled properly.
master
Christoph M. Becker 2017-01-24 00:03:02 +01:00
parent bffad4da3c
commit 106834014b
5 changed files with 32 additions and 0 deletions

View File

@ -1,4 +1,5 @@
/bug_289
/bug00209
/bug00309
/bug00354
/gd2_empty_file

View File

@ -1,5 +1,6 @@
LIST(APPEND TESTS_FILES
bug_289
bug00209
bug00309
bug00354
gd2_empty_file

View File

@ -1,5 +1,6 @@
libgd_test_programs += \
gd2/bug_289 \
gd2/bug00209 \
gd2/bug00309 \
gd2/bug00354 \
gd2/gd2_empty_file \
@ -20,6 +21,7 @@ endif
EXTRA_DIST += \
gd2/CMakeLists.txt \
gd2/bug00209.gd2 \
gd2/bug00354a.gd2 \
gd2/bug00354b.gd2 \
gd2/conv_gd2_exp.gd2 \

28
tests/gd2/bug00209.c Normal file
View File

@ -0,0 +1,28 @@
/**
* Regression test for github issue #209
*
* We're testing that bug00209.gd2, which claims to have 12336 x 48 pixels, but
* actually provides not enough image data, is rejected, i.e. that
* gdImageCreateFromGd2() returns NULL
*
* See <https://github.com/libgd/libgd/issues/209>.
*/
#include "gd.h"
#include "gdtest.h"
int main()
{
gdImagePtr im;
FILE *fp;
fp = gdTestFileOpen2("gd2", "bug00209.gd2");
gdTestAssert(fp != NULL);
im = gdImageCreateFromGd2(fp);
gdTestAssert(im == NULL);
fclose(fp);
return gdNumFailures();
}

BIN
tests/gd2/bug00209.gd2 Normal file

Binary file not shown.