diff options
Diffstat (limited to 'Build/source/libs/gd/libgd-src/tests/xbm')
7 files changed, 81 insertions, 34 deletions
diff --git a/Build/source/libs/gd/libgd-src/tests/xbm/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/xbm/CMakeLists.txt index 3e3bb696cad..2447fd54d67 100644 --- a/Build/source/libs/gd/libgd-src/tests/xbm/CMakeLists.txt +++ b/Build/source/libs/gd/libgd-src/tests/xbm/CMakeLists.txt @@ -1,7 +1,11 @@ +LIST(APPEND TESTS_FILES + github_bug_501 + github_bug_170 +) + IF(PNG_FOUND) LIST(APPEND TESTS_FILES github_bug_109 - github_bug_170 x10_basic_read ) ENDIF(PNG_FOUND) diff --git a/Build/source/libs/gd/libgd-src/tests/xbm/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/xbm/Makemodule.am index a9a293d1612..4d14916b133 100644 --- a/Build/source/libs/gd/libgd-src/tests/xbm/Makemodule.am +++ b/Build/source/libs/gd/libgd-src/tests/xbm/Makemodule.am @@ -1,7 +1,10 @@ +libgd_test_programs += \ + xbm/github_bug_501 \ + xbm/github_bug_170 + if HAVE_LIBPNG libgd_test_programs += \ xbm/github_bug_109 \ - xbm/github_bug_170 \ xbm/x10_basic_read endif @@ -10,4 +13,5 @@ EXTRA_DIST += \ xbm/github_bug_109.xbm \ xbm/github_bug_109_exp.png \ xbm/x10_basic_read.xbm \ - xbm/x10_basic_read_exp.png + xbm/x10_basic_read_exp.png \ + xbm/github_bug_501.xbm diff --git a/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_109.c b/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_109.c index c0b50a8f0d4..70b793738e1 100644 --- a/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_109.c +++ b/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_109.c @@ -7,29 +7,27 @@ * See also <https://github.com/libgd/libgd/issues/109>. */ - #include "gd.h" #include "gdtest.h" - int main() { - gdImagePtr im; - FILE *fp; - char *path; + gdImagePtr im; + FILE *fp; + char *path; - fp = gdTestFileOpen2("xbm", "github_bug_109.xbm"); - im = gdImageCreateFromXbm(fp); - fclose(fp); - gdTestAssert(im != NULL); - gdTestAssert(gdImageGetTrueColorPixel(im, 0, 0) == 0); - gdTestAssert(gdImageGetTrueColorPixel(im, 0, 1) == 0xffffff); + fp = gdTestFileOpen2("xbm", "github_bug_109.xbm"); + im = gdImageCreateFromXbm(fp); + fclose(fp); + gdTestAssert(im != NULL); + gdTestAssert(gdImageGetTrueColorPixel(im, 0, 0) == 0); + gdTestAssert(gdImageGetTrueColorPixel(im, 0, 1) == 0xffffff); - path = gdTestFilePath2("xbm", "github_bug_109_exp.png"); - gdAssertImageEqualsToFile(path, im); - gdFree(path); + path = gdTestFilePath2("xbm", "github_bug_109_exp.png"); + gdAssertImageEqualsToFile(path, im); + gdFree(path); - gdImageDestroy(im); + gdImageDestroy(im); - return gdNumFailures(); + return gdNumFailures(); } diff --git a/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_170.c b/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_170.c index 3900da7b1b6..8134fb82fdb 100644 --- a/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_170.c +++ b/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_170.c @@ -47,4 +47,4 @@ int main() gdTestAssertMsg(length == 250, "expected to write 250 bytes; %jd bytes written", (intmax_t) length); return gdNumFailures(); } -#endif
\ No newline at end of file +#endif diff --git a/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_501.c b/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_501.c new file mode 100644 index 00000000000..5d8bfd76b80 --- /dev/null +++ b/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_501.c @@ -0,0 +1,39 @@ +/* + Test reading an invalid XBM image. + + The pixels of the XBM image are invalid hex which makes the uninitialezed + variable be encoded into the output image i.e. information disclosure. + The image is 8*2. + + See also <https://github.com/libgd/libgd/issues/501>. +*/ + +#include "gd.h" +#include "gdtest.h" + +int main() +{ + + gdImagePtr im; + FILE *fp; + + fp = gdTestFileOpen2("xbm", "github_bug_501.xbm"); + im = gdImageCreateFromXbm(fp); + + gdTestAssert(im == NULL); + + if (im) { + gdTestErrorMsg("Info Disclosed\n"); + int i; + for (i = 0; i < 8; i++) { + printf("Pixel(%d, 0) %0x\n", i, gdImageGetPixel(im, i, 0)); + } + for (i = 0; i < 8; i++) { + printf("Pixel(%d, 1) %0x\n", i, gdImageGetPixel(im, i, 1)); + } + gdImageDestroy(im); + } + + fclose(fp); + return gdNumFailures(); +} diff --git a/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_501.xbm b/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_501.xbm new file mode 100644 index 00000000000..41ad301e7fe --- /dev/null +++ b/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_501.xbm @@ -0,0 +1,4 @@ +#define width 8 +#define height 2 +static char bits[] ={ +xzzxzz diff --git a/Build/source/libs/gd/libgd-src/tests/xbm/x10_basic_read.c b/Build/source/libs/gd/libgd-src/tests/xbm/x10_basic_read.c index 99b9019c5f7..f7c505e55b7 100644 --- a/Build/source/libs/gd/libgd-src/tests/xbm/x10_basic_read.c +++ b/Build/source/libs/gd/libgd-src/tests/xbm/x10_basic_read.c @@ -6,27 +6,25 @@ * which is 2 bytes instead of 1, and the endianess. */ - #include "gd.h" #include "gdtest.h" - int main() { - gdImagePtr im; - FILE *fp; - char *path; + gdImagePtr im; + FILE *fp; + char *path; - fp = gdTestFileOpen2("xbm", "x10_basic_read.xbm"); - im = gdImageCreateFromXbm(fp); - fclose(fp); - gdTestAssert(im != NULL); + fp = gdTestFileOpen2("xbm", "x10_basic_read.xbm"); + im = gdImageCreateFromXbm(fp); + fclose(fp); + gdTestAssert(im != NULL); - path = gdTestFilePath2("xbm", "x10_basic_read_exp.png"); - gdAssertImageEqualsToFile(path, im); - gdFree(path); + path = gdTestFilePath2("xbm", "x10_basic_read_exp.png"); + gdAssertImageEqualsToFile(path, im); + gdFree(path); - gdImageDestroy(im); + gdImageDestroy(im); - return gdNumFailures(); + return gdNumFailures(); } |