diff --git a/tests/pngsuite/iphone/iphone_basi0g01.png b/tests/pngsuite/iphone/iphone_basi0g01.png new file mode 100644 index 0000000..33db08c Binary files /dev/null and b/tests/pngsuite/iphone/iphone_basi0g01.png differ diff --git a/tests/pngsuite/iphone/iphone_basi0g02.png b/tests/pngsuite/iphone/iphone_basi0g02.png new file mode 100644 index 0000000..484f46d Binary files /dev/null and b/tests/pngsuite/iphone/iphone_basi0g02.png differ diff --git a/tests/pngsuite/iphone/iphone_basi3p02.png b/tests/pngsuite/iphone/iphone_basi3p02.png new file mode 100644 index 0000000..1699e9a Binary files /dev/null and b/tests/pngsuite/iphone/iphone_basi3p02.png differ diff --git a/tests/pngsuite/iphone/iphone_bgwn6a08.png b/tests/pngsuite/iphone/iphone_bgwn6a08.png new file mode 100644 index 0000000..7d0ac50 Binary files /dev/null and b/tests/pngsuite/iphone/iphone_bgwn6a08.png differ diff --git a/tests/pngsuite/iphone/iphone_bgyn6a16.png b/tests/pngsuite/iphone/iphone_bgyn6a16.png new file mode 100644 index 0000000..9046336 Binary files /dev/null and b/tests/pngsuite/iphone/iphone_bgyn6a16.png differ diff --git a/tests/pngsuite/iphone/iphone_tbyn3p08.png b/tests/pngsuite/iphone/iphone_tbyn3p08.png new file mode 100644 index 0000000..3c224d0 Binary files /dev/null and b/tests/pngsuite/iphone/iphone_tbyn3p08.png differ diff --git a/tests/pngsuite/iphone/iphone_z06n2c08.png b/tests/pngsuite/iphone/iphone_z06n2c08.png new file mode 100644 index 0000000..de5dba3 Binary files /dev/null and b/tests/pngsuite/iphone/iphone_z06n2c08.png differ diff --git a/tests/stb_png.dict b/tests/stb_png.dict new file mode 100644 index 0000000..2a27994 --- /dev/null +++ b/tests/stb_png.dict @@ -0,0 +1,8 @@ +header_png="\x89PNG\x0d\x0a\x1a\x0a" + +section_idat="IDAT" +section_iend="IEND" +section_ihdr="IHDR" +section_plte="PLTE" +section_trns="tRNS" +section_cgbi="CgBI" diff --git a/tests/stb_png_read_fuzzer.cpp b/tests/stb_png_read_fuzzer.cpp new file mode 100644 index 0000000..0e14e1b --- /dev/null +++ b/tests/stb_png_read_fuzzer.cpp @@ -0,0 +1,19 @@ +#define STB_IMAGE_IMPLEMENTATION +#define STBI_ONLY_PNG +#include "../stb_image.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + int x, y, channels; + + if(!stbi_info_from_memory(data, size, &x, &y, &channels)) return 0; + + /* exit if the image is larger than ~80MB */ + if(y && x > (80000000 / 4) / y) return 0; + + unsigned char *img = stbi_load_from_memory(data, size, &x, &y, &channels, 4); + + free(img); + + return 0; +} diff --git a/tests/stb_png_read_fuzzer.options b/tests/stb_png_read_fuzzer.options new file mode 100644 index 0000000..e0c8a84 --- /dev/null +++ b/tests/stb_png_read_fuzzer.options @@ -0,0 +1,2 @@ +[libfuzzer] +dict = stb_png.dict