com php-fuzzing-sapi: Add EXIF fuzzer: Makefile.frag config.m4 corpus/exif/bug34704.jpg corpus/exif/bug34704_2 .jpg corpus/exif/bug48378.jpeg
corpus/exif/bu g54002_1.jpeg corpus/exif/bug54002 _2.jpeg corpus/exif/bug62523_1.jpg co rpus/exif/bug62523_3.jpg corpus/exif/bug6 8113.jpg
corpus/exif/bug68113_2.jpg corpus/exif/bug68799.jpg corpus/exif/bug72 094_1.jpg corpus/exif/bug72094_2. jpg corpus/exif/bug72094_3.jpg corpus/exif/
bug72094_4.jpg corpus/exif/bu
| From: | Johannes Schlüter | Date: | Mon, 04 Mar 2019 22:26:17 +0000 |
| Subject: | com php-fuzzing-sapi: Add EXIF fuzzer: Makefile.frag config.m4 corpus/exif/bug34704.jpg corpus/exif/bug34704_2 .jpg corpus/exif/bug48378.jpeg corpus/exif/bu g54002_1.jpeg corpus/exif/bug54002 _2.jpeg corpus/exif/bug62523_1.jpg co rpus/exif/bug62523_3.jpg corpus/exif/bug6 8113.jpg corpus/exif/bug68113_2.jpg corpus/exif/bug68799.jpg corpus/exif/bug72 094_1.jpg corpus/exif/bug72094_2. jpg corpus/exif/bug72094_3.jpg corpus/exif/ bug72094_4.jpg corpus/exif/bu |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105127@lists.php.net to get a copy of this message | ||
Commit: 6c46692bbd93b17bddbc54d526368181adc1ed45
Author: Stanislav Malyshev <smalyshev@gmail.com> Mon, 4 Mar 2019 13:01:24 -0800
Parents: 8e5e991e8f72db50e52e6636d3028ed27830c286
Branches: master
Link: http://git.php.net/?p=php-fuzzing-sapi.git;a=commitdiff;h=6c46692bbd93b17bddbc54d526368181adc1ed45
Log:
Add EXIF fuzzer
Changed paths:
M Makefile.frag
M config.m4
A corpus/exif/bug34704.jpg
A corpus/exif/bug34704_2.jpg
A corpus/exif/bug48378.jpeg
A corpus/exif/bug54002_1.jpeg
A corpus/exif/bug54002_2.jpeg
A corpus/exif/bug62523_1.jpg
A corpus/exif/bug62523_3.jpg
A corpus/exif/bug68113.jpg
A corpus/exif/bug68113_2.jpg
A corpus/exif/bug68799.jpg
A corpus/exif/bug72094_1.jpg
A corpus/exif/bug72094_2..jpg
A corpus/exif/bug72094_3.jpg
A corpus/exif/bug72094_4.jpg
A corpus/exif/bug72603.jpeg
A corpus/exif/bug72618.jpg
A corpus/exif/bug72627.tiff
A corpus/exif/bug73737.tiff
A corpus/exif/bug76130_1.jpg
A corpus/exif/bug76130_2.jpg
A corpus/exif/bug76423.jpg
A corpus/exif/bug76557.jpg
A corpus/exif/bug77540.jpg
A corpus/exif/bug77563.jpg
A corpus/exif/exif_encoding_crash.jpg
A corpus/exif/image007.jpg
A corpus/exif/image008.jpg
A corpus/exif/image009.jpg
A corpus/exif/image010.jpg
A corpus/exif/image011.jpg
A corpus/exif/image012.jpg
A corpus/exif/image013.jpg
A corpus/exif/image014.jpg
A corpus/exif/image015.jpg
A corpus/exif/image016.tiff
A corpus/exif/image017.tiff
A corpus/exif/image018.tiff
A corpus/exif/image020.tiff
A corpus/exif/image021.tiff
A corpus/exif/image022.tiff
A corpus/exif/image023.tiff
A corpus/exif/image024.jpg
A corpus/exif/image025.jpg
A corpus/exif/image026.tiff
A corpus/exif/image027.tiff
A corpus/exif/test1.jpg
A corpus/exif/test2.jpg
A corpus/exif/test22.jpg
A corpus/exif/test3.jpg
A corpus/exif/test4.jpg
A corpus/exif/test5.jpg
A corpus/exif/test6.jpg
A fuzzer-exif.c
diff --git a/Makefile.frag b/Makefile.frag index b1398d8..2f5a7dd 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -8,3 +8,6 @@ $(SAPI_FUZZER_PATH)/php-fuzz-unserialize: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $( $(SAPI_FUZZER_PATH)/php-fuzz-json: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(PHP_FUZZER_JSON_OBJS) $(LIBTOOL) --mode=link $(FUZZING_CC) -export-dynamic $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS_PROGRAM) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FUZZER_JSON_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(FUZZING_LIB) -o $(SAPI_FUZZER_PATH)/php-fuzz-json + +$(SAPI_FUZZER_PATH)/php-fuzz-exif: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(PHP_FUZZER_EXIF_OBJS) + $(LIBTOOL) --mode=link $(FUZZING_CC) -export-dynamic $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS_PROGRAM) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FUZZER_EXIF_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(FUZZING_LIB) -o $(SAPI_FUZZER_PATH)/php-fuzz-exif diff --git a/config.m4 b/config.m4 index bc52df3..78e3e16 100644 --- a/config.m4 +++ b/config.m4 @@ -42,7 +42,11 @@ if test "$PHP_FUZZER" != "no"; then PHP_SUBST(PHP_FUZZER_UNSERIALIZE_OBJS) PHP_ADD_SOURCES_X([sapi/fuzzer],[fuzzer-unserialize.c fuzzer-sapi.c],[],PHP_FUZZER_UNSERIALIZE_OBJS) - dnl This check doesn't work, as PHP_ARG_ENABLE(json) comes later ... + PHP_FUZZER_BINARIES="$PHP_FUZZER_BINARIES $SAPI_FUZZER_PATH/php-fuzz-exif" + PHP_SUBST(PHP_FUZZER_EXIF_OBJS) + PHP_ADD_SOURCES_X([sapi/fuzzer],[fuzzer-exif.c fuzzer-sapi.c],[],PHP_FUZZER_EXIF_OBJS) + + dnl This check doesn't work, as PHP_ARG_ENABLE(json) comes later ... if test "$PHP_JSON" != "no"; then PHP_FUZZER_BINARIES="$PHP_FUZZER_BINARIES $SAPI_FUZZER_PATH/php-fuzz-json" PHP_SUBST(PHP_FUZZER_JSON_OBJS) diff --git a/corpus/exif/bug34704.jpg b/corpus/exif/bug34704.jpg new file mode 100755 index 0000000..42b14c1 Binary files /dev/null and b/corpus/exif/bug34704.jpg differ diff --git a/corpus/exif/bug34704_2.jpg b/corpus/exif/bug34704_2.jpg new file mode 100644 index 0000000..42b14c1 Binary files /dev/null and b/corpus/exif/bug34704_2.jpg differ diff --git a/corpus/exif/bug48378.jpeg b/corpus/exif/bug48378.jpeg new file mode 100644 index 0000000..759d805 Binary files /dev/null and b/corpus/exif/bug48378.jpeg differ diff --git a/corpus/exif/bug54002_1.jpeg b/corpus/exif/bug54002_1.jpeg new file mode 100644 index 0000000..a622d6d Binary files /dev/null and b/corpus/exif/bug54002_1.jpeg differ diff --git a/corpus/exif/bug54002_2.jpeg b/corpus/exif/bug54002_2.jpeg new file mode 100644 index 0000000..a622d6d Binary files /dev/null and b/corpus/exif/bug54002_2.jpeg differ diff --git a/corpus/exif/bug62523_1.jpg b/corpus/exif/bug62523_1.jpg new file mode 100644 index 0000000..9a63d1e --- /dev/null +++ b/corpus/exif/bug62523_1.jpg @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> +<html><head> +<title>301 Moved Permanently</title> +</head><body> +<h1>Moved Permanently</h1> +<p>The document has moved <a href="http://www.getid3.org/temp/62523.jpg">here</a>.</p> +<hr> +<address>Apache Server at getid3.org Port 80</address> +</body></html> diff --git a/corpus/exif/bug62523_3.jpg b/corpus/exif/bug62523_3.jpg new file mode 100644 index 0000000..3ee9136 --- /dev/null +++ b/corpus/exif/bug62523_3.jpg @@ -0,0 +1,12 @@ +<html> + <head><title>Found</title></head> + <body> + <h1>Found</h1> + <p>The resource was found at <a href="http://dl.dropboxusercontent.com/u/7562584/Bugs/Php/bad_exif.jpeg">http://dl.dropboxusercontent.com/u/7562584/Bugs/Php/bad_exif.jpeg</a>; +you should be redirected automatically. + +<!-- --></p> + <hr noshade> + <div align="right">WSGI Server</div> + </body> +</html> diff --git a/corpus/exif/bug68113.jpg b/corpus/exif/bug68113.jpg new file mode 100755 index 0000000..3ce7a62 Binary files /dev/null and b/corpus/exif/bug68113.jpg differ diff --git a/corpus/exif/bug68113_2.jpg b/corpus/exif/bug68113_2.jpg new file mode 100644 index 0000000..3ce7a62 Binary files /dev/null and b/corpus/exif/bug68113_2.jpg differ diff --git a/corpus/exif/bug68799.jpg b/corpus/exif/bug68799.jpg new file mode 100644 index 0000000..acc326d Binary files /dev/null and b/corpus/exif/bug68799.jpg differ diff --git a/corpus/exif/bug72094_1.jpg b/corpus/exif/bug72094_1.jpg new file mode 100644 index 0000000..d21382b Binary files /dev/null and b/corpus/exif/bug72094_1.jpg differ diff --git a/corpus/exif/bug72094_2.jpg b/corpus/exif/bug72094_2.jpg new file mode 100644 index 0000000..ec414ce Binary files /dev/null and b/corpus/exif/bug72094_2.jpg differ diff --git a/corpus/exif/bug72094_3.jpg b/corpus/exif/bug72094_3.jpg new file mode 100644 index 0000000..8b05314 Binary files /dev/null and b/corpus/exif/bug72094_3.jpg differ diff --git a/corpus/exif/bug72094_4.jpg b/corpus/exif/bug72094_4.jpg new file mode 100644 index 0000000..ca6d453 Binary files /dev/null and b/corpus/exif/bug72094_4.jpg differ diff --git a/corpus/exif/bug72603.jpeg b/corpus/exif/bug72603.jpeg new file mode 100644 index 0000000..1764c80 Binary files /dev/null and b/corpus/exif/bug72603.jpeg differ diff --git a/corpus/exif/bug72618.jpg b/corpus/exif/bug72618.jpg new file mode 100644 index 0000000..0a61ae2 Binary files /dev/null and b/corpus/exif/bug72618.jpg differ diff --git a/corpus/exif/bug72627.tiff b/corpus/exif/bug72627.tiff new file mode 100644 index 0000000..229190a Binary files /dev/null and b/corpus/exif/bug72627.tiff differ diff --git a/corpus/exif/bug73737.tiff b/corpus/exif/bug73737.tiff new file mode 100644 index 0000000..2cb036f Binary files /dev/null and b/corpus/exif/bug73737.tiff differ diff --git a/corpus/exif/bug76130_1.jpg b/corpus/exif/bug76130_1.jpg new file mode 100644 index 0000000..e063e46 Binary files /dev/null and b/corpus/exif/bug76130_1.jpg differ diff --git a/corpus/exif/bug76130_2.jpg b/corpus/exif/bug76130_2.jpg new file mode 100644 index 0000000..a9e79dc Binary files /dev/null and b/corpus/exif/bug76130_2.jpg differ diff --git a/corpus/exif/bug76423.jpg b/corpus/exif/bug76423.jpg new file mode 100644 index 0000000..08fe2bb Binary files /dev/null and b/corpus/exif/bug76423.jpg differ diff --git a/corpus/exif/bug76557.jpg b/corpus/exif/bug76557.jpg new file mode 100644 index 0000000..d678f07 Binary files /dev/null and b/corpus/exif/bug76557.jpg differ diff --git a/corpus/exif/bug77540.jpg b/corpus/exif/bug77540.jpg new file mode 100644 index 0000000..559022d Binary files /dev/null and b/corpus/exif/bug77540.jpg differ diff --git a/corpus/exif/bug77563.jpg b/corpus/exif/bug77563.jpg new file mode 100644 index 0000000..d628015 Binary files /dev/null and b/corpus/exif/bug77563.jpg differ diff --git a/corpus/exif/exif_encoding_crash.jpg b/corpus/exif/exif_encoding_crash.jpg new file mode 100644 index 0000000..55138ab Binary files /dev/null and b/corpus/exif/exif_encoding_crash.jpg differ diff --git a/corpus/exif/image007.jpg b/corpus/exif/image007.jpg new file mode 100644 index 0000000..8526540 Binary files /dev/null and b/corpus/exif/image007.jpg differ diff --git a/corpus/exif/image008.jpg b/corpus/exif/image008.jpg new file mode 100644 index 0000000..3e8bfe4 Binary files /dev/null and b/corpus/exif/image008.jpg differ diff --git a/corpus/exif/image009.jpg b/corpus/exif/image009.jpg new file mode 100644 index 0000000..8803ddc Binary files /dev/null and b/corpus/exif/image009.jpg differ diff --git a/corpus/exif/image010.jpg b/corpus/exif/image010.jpg new file mode 100644 index 0000000..31ed6d6 Binary files /dev/null and b/corpus/exif/image010.jpg differ diff --git a/corpus/exif/image011.jpg b/corpus/exif/image011.jpg new file mode 100644 index 0000000..fcd5783 Binary files /dev/null and b/corpus/exif/image011.jpg differ diff --git a/corpus/exif/image012.jpg b/corpus/exif/image012.jpg new file mode 100644 index 0000000..dd25e06 Binary files /dev/null and b/corpus/exif/image012.jpg differ diff --git a/corpus/exif/image013.jpg b/corpus/exif/image013.jpg new file mode 100644 index 0000000..93ded26 Binary files /dev/null and b/corpus/exif/image013.jpg differ diff --git a/corpus/exif/image014.jpg b/corpus/exif/image014.jpg new file mode 100644 index 0000000..7657a0a Binary files /dev/null and b/corpus/exif/image014.jpg differ diff --git a/corpus/exif/image015.jpg b/corpus/exif/image015.jpg new file mode 100644 index 0000000..6f52dec Binary files /dev/null and b/corpus/exif/image015.jpg differ diff --git a/corpus/exif/image016.tiff b/corpus/exif/image016.tiff new file mode 100644 index 0000000..1712113 Binary files /dev/null and b/corpus/exif/image016.tiff differ diff --git a/corpus/exif/image017.tiff b/corpus/exif/image017.tiff new file mode 100644 index 0000000..89800d8 Binary files /dev/null and b/corpus/exif/image017.tiff differ diff --git a/corpus/exif/image018.tiff b/corpus/exif/image018.tiff new file mode 100644 index 0000000..6b4492f Binary files /dev/null and b/corpus/exif/image018.tiff differ diff --git a/corpus/exif/image020.tiff b/corpus/exif/image020.tiff new file mode 100644 index 0000000..87f1878 Binary files /dev/null and b/corpus/exif/image020.tiff differ diff --git a/corpus/exif/image021.tiff b/corpus/exif/image021.tiff new file mode 100644 index 0000000..190f30b Binary files /dev/null and b/corpus/exif/image021.tiff differ diff --git a/corpus/exif/image022.tiff b/corpus/exif/image022.tiff new file mode 100644 index 0000000..88f4373 Binary files /dev/null and b/corpus/exif/image022.tiff differ diff --git a/corpus/exif/image023.tiff b/corpus/exif/image023.tiff new file mode 100644 index 0000000..dc33f6e Binary files /dev/null and b/corpus/exif/image023.tiff differ diff --git a/corpus/exif/image024.jpg b/corpus/exif/image024.jpg new file mode 100644 index 0000000..0b5a42e Binary files /dev/null and b/corpus/exif/image024.jpg differ diff --git a/corpus/exif/image025.jpg b/corpus/exif/image025.jpg new file mode 100644 index 0000000..a5c0e17 Binary files /dev/null and b/corpus/exif/image025.jpg differ diff --git a/corpus/exif/image026.tiff b/corpus/exif/image026.tiff new file mode 100644 index 0000000..8fdafc7 Binary files /dev/null and b/corpus/exif/image026.tiff differ diff --git a/corpus/exif/image027.tiff b/corpus/exif/image027.tiff new file mode 100644 index 0000000..7c3a37a Binary files /dev/null and b/corpus/exif/image027.tiff differ diff --git a/corpus/exif/test1.jpg b/corpus/exif/test1.jpg new file mode 100644 index 0000000..121decb Binary files /dev/null and b/corpus/exif/test1.jpg differ diff --git a/corpus/exif/test2.jpg b/corpus/exif/test2.jpg new file mode 100644 index 0000000..f60ecde Binary files /dev/null and b/corpus/exif/test2.jpg differ diff --git a/corpus/exif/test22.jpg b/corpus/exif/test22.jpg new file mode 100644 index 0000000..f60ecde Binary files /dev/null and b/corpus/exif/test22.jpg differ diff --git a/corpus/exif/test3.jpg b/corpus/exif/test3.jpg new file mode 100644 index 0000000..7547a16 Binary files /dev/null and b/corpus/exif/test3.jpg differ diff --git a/corpus/exif/test4.jpg b/corpus/exif/test4.jpg new file mode 100644 index 0000000..8a23a7b Binary files /dev/null and b/corpus/exif/test4.jpg differ diff --git a/corpus/exif/test5.jpg b/corpus/exif/test5.jpg new file mode 100644 index 0000000..d03cac1 Binary files /dev/null and b/corpus/exif/test5.jpg differ diff --git a/corpus/exif/test6.jpg b/corpus/exif/test6.jpg new file mode 100644 index 0000000..073cefd Binary files /dev/null and b/corpus/exif/test6.jpg differ diff --git a/fuzzer-exif.c b/fuzzer-exif.c new file mode 100644 index 0000000..296f9fc --- /dev/null +++ b/fuzzer-exif.c @@ -0,0 +1,87 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 2017, Johannes Schlüter <johannes@schlueters.de> | + | All rights reserved. | + +----------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions which are | + | bundled with this package in the file LICENSE. | + | This product includes PHP software, freely available from | + | <http://www.php.net/software/> | + +----------------------------------------------------------------------+ +*/ + +#include "fuzzer.h" + +#include "Zend/zend.h" +#include "main/php_config.h" +#include "main/php_main.h" +#include "ext/standard/php_var.h" + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include "fuzzer-sapi.h" + +int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + char *filename; + int filedes, result; + zend_fcall_info fci = {0}; + zend_fcall_info_cache fci_cache = {0}; + zval args[1], retval, func; + + if (php_request_startup()==FAILURE) { + php_module_shutdown(); + return 0; + } + + /* put the data in a file */ + filename = tmpnam(NULL); + filedes = open(filename, O_CREAT|O_RDWR); + write(filedes, Data, Size); + close(filedes); + + ZVAL_STRING(&func, "exif_read_data"); + + zend_fcall_info_init(&func, 0, &fci, &fci_cache, NULL, NULL); + + ZVAL_STRING(&args[0], filename); + fci.retval = &retval; + fci.param_count = 1; + fci.params = args; + fci.no_separation = 0; + + result = zend_call_function(&fci, &fci_cache); + /* to ensure retval is not broken */ + php_var_dump(&retval, 0); + + /* cleanup */ + ZVAL_UNDEF(&retval); + ZVAL_UNDEF(&args[0]); + ZVAL_UNDEF(&func); + unlink(filename); + php_request_shutdown(NULL); + + return 0; +} + +int LLVMFuzzerInitialize(int *argc, char ***argv) { + fuzzer_init_php(); + + /* fuzzer_shutdown_php(); */ + return 0; +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ +
diff --git a/Makefile.frag b/Makefile.frag index b1398d8..2f5a7dd 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -8,3 +8,6 @@ $(SAPI_FUZZER_PATH)/php-fuzz-unserialize: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $( $(SAPI_FUZZER_PATH)/php-fuzz-json: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(PHP_FUZZER_JSON_OBJS) $(LIBTOOL) --mode=link $(FUZZING_CC) -export-dynamic $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS_PROGRAM) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FUZZER_JSON_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(FUZZING_LIB) -o $(SAPI_FUZZER_PATH)/php-fuzz-json + +$(SAPI_FUZZER_PATH)/php-fuzz-exif: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(PHP_FUZZER_EXIF_OBJS) + $(LIBTOOL) --mode=link $(FUZZING_CC) -export-dynamic $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS_PROGRAM) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FUZZER_EXIF_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(FUZZING_LIB) -o $(SAPI_FUZZER_PATH)/php-fuzz-exif diff --git a/config.m4 b/config.m4 index bc52df3..78e3e16 100644 --- a/config.m4 +++ b/config.m4 @@ -42,7 +42,11 @@ if test "$PHP_FUZZER" != "no"; then PHP_SUBST(PHP_FUZZER_UNSERIALIZE_OBJS) PHP_ADD_SOURCES_X([sapi/fuzzer],[fuzzer-unserialize.c fuzzer-sapi.c],[],PHP_FUZZER_UNSERIALIZE_OBJS) - dnl This check doesn't work, as PHP_ARG_ENABLE(json) comes later ... + PHP_FUZZER_BINARIES="$PHP_FUZZER_BINARIES $SAPI_FUZZER_PATH/php-fuzz-exif" + PHP_SUBST(PHP_FUZZER_EXIF_OBJS) + PHP_ADD_SOURCES_X([sapi/fuzzer],[fuzzer-exif.c fuzzer-sapi.c],[],PHP_FUZZER_EXIF_OBJS) + + dnl This check doesn't work, as PHP_ARG_ENABLE(json) comes later ... if test "$PHP_JSON" != "no"; then PHP_FUZZER_BINARIES="$PHP_FUZZER_BINARIES $SAPI_FUZZER_PATH/php-fuzz-json" PHP_SUBST(PHP_FUZZER_JSON_OBJS) diff --git a/corpus/exif/bug34704.jpg b/corpus/exif/bug34704.jpg new file mode 100755 index 0000000..42b14c1 Binary files /dev/null and b/corpus/exif/bug34704.jpg differ diff --git a/corpus/exif/bug34704_2.jpg b/corpus/exif/bug34704_2.jpg new file mode 100644 index 0000000..42b14c1 Binary files /dev/null and b/corpus/exif/bug34704_2.jpg differ diff --git a/corpus/exif/bug48378.jpeg b/corpus/exif/bug48378.jpeg new file mode 100644 index 0000000..759d805 Binary files /dev/null and b/corpus/exif/bug48378.jpeg differ diff --git a/corpus/exif/bug54002_1.jpeg b/corpus/exif/bug54002_1.jpeg new file mode 100644 index 0000000..a622d6d Binary files /dev/null and b/corpus/exif/bug54002_1.jpeg differ diff --git a/corpus/exif/bug54002_2.jpeg b/corpus/exif/bug54002_2.jpeg new file mode 100644 index 0000000..a622d6d Binary files /dev/null and b/corpus/exif/bug54002_2.jpeg differ diff --git a/corpus/exif/bug62523_1.jpg b/corpus/exif/bug62523_1.jpg new file mode 100644 index 0000000..9a63d1e --- /dev/null +++ b/corpus/exif/bug62523_1.jpg @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> +<html><head> +<title>301 Moved Permanently</title> +</head><body> +<h1>Moved Permanently</h1> +<p>The document has moved <a href="http://www.getid3.org/temp/62523.jpg">here</a>.</p> +<hr> +<address>Apache Server at getid3.org Port 80</address> +</body></html> diff --git a/corpus/exif/bug62523_3.jpg b/corpus/exif/bug62523_3.jpg new file mode 100644 index 0000000..3ee9136 --- /dev/null +++ b/corpus/exif/bug62523_3.jpg @@ -0,0 +1,12 @@ +<html> + <head><title>Found</title></head> + <body> + <h1>Found</h1> + <p>The resource was found at <a href="http://dl.dropboxusercontent.com/u/7562584/Bugs/Php/bad_exif.jpeg">http://dl.dropboxusercontent.com/u/7562584/Bugs/Php/bad_exif.jpeg</a>; +you should be redirected automatically. + +<!-- --></p> + <hr noshade> + <div align="right">WSGI Server</div> + </body> +</html> diff --git a/corpus/exif/bug68113.jpg b/corpus/exif/bug68113.jpg new file mode 100755 index 0000000..3ce7a62 Binary files /dev/null and b/corpus/exif/bug68113.jpg differ diff --git a/corpus/exif/bug68113_2.jpg b/corpus/exif/bug68113_2.jpg new file mode 100644 index 0000000..3ce7a62 Binary files /dev/null and b/corpus/exif/bug68113_2.jpg differ diff --git a/corpus/exif/bug68799.jpg b/corpus/exif/bug68799.jpg new file mode 100644 index 0000000..acc326d Binary files /dev/null and b/corpus/exif/bug68799.jpg differ diff --git a/corpus/exif/bug72094_1.jpg b/corpus/exif/bug72094_1.jpg new file mode 100644 index 0000000..d21382b Binary files /dev/null and b/corpus/exif/bug72094_1.jpg differ diff --git a/corpus/exif/bug72094_2.jpg b/corpus/exif/bug72094_2.jpg new file mode 100644 index 0000000..ec414ce Binary files /dev/null and b/corpus/exif/bug72094_2.jpg differ diff --git a/corpus/exif/bug72094_3.jpg b/corpus/exif/bug72094_3.jpg new file mode 100644 index 0000000..8b05314 Binary files /dev/null and b/corpus/exif/bug72094_3.jpg differ diff --git a/corpus/exif/bug72094_4.jpg b/corpus/exif/bug72094_4.jpg new file mode 100644 index 0000000..ca6d453 Binary files /dev/null and b/corpus/exif/bug72094_4.jpg differ diff --git a/corpus/exif/bug72603.jpeg b/corpus/exif/bug72603.jpeg new file mode 100644 index 0000000..1764c80 Binary files /dev/null and b/corpus/exif/bug72603.jpeg differ diff --git a/corpus/exif/bug72618.jpg b/corpus/exif/bug72618.jpg new file mode 100644 index 0000000..0a61ae2 Binary files /dev/null and b/corpus/exif/bug72618.jpg differ diff --git a/corpus/exif/bug72627.tiff b/corpus/exif/bug72627.tiff new file mode 100644 index 0000000..229190a Binary files /dev/null and b/corpus/exif/bug72627.tiff differ diff --git a/corpus/exif/bug73737.tiff b/corpus/exif/bug73737.tiff new file mode 100644 index 0000000..2cb036f Binary files /dev/null and b/corpus/exif/bug73737.tiff differ diff --git a/corpus/exif/bug76130_1.jpg b/corpus/exif/bug76130_1.jpg new file mode 100644 index 0000000..e063e46 Binary files /dev/null and b/corpus/exif/bug76130_1.jpg differ diff --git a/corpus/exif/bug76130_2.jpg b/corpus/exif/bug76130_2.jpg new file mode 100644 index 0000000..a9e79dc Binary files /dev/null and b/corpus/exif/bug76130_2.jpg differ diff --git a/corpus/exif/bug76423.jpg b/corpus/exif/bug76423.jpg new file mode 100644 index 0000000..08fe2bb Binary files /dev/null and b/corpus/exif/bug76423.jpg differ diff --git a/corpus/exif/bug76557.jpg b/corpus/exif/bug76557.jpg new file mode 100644 index 0000000..d678f07 Binary files /dev/null and b/corpus/exif/bug76557.jpg differ diff --git a/corpus/exif/bug77540.jpg b/corpus/exif/bug77540.jpg new file mode 100644 index 0000000..559022d Binary files /dev/null and b/corpus/exif/bug77540.jpg differ diff --git a/corpus/exif/bug77563.jpg b/corpus/exif/bug77563.jpg new file mode 100644 index 0000000..d628015 Binary files /dev/null and b/corpus/exif/bug77563.jpg differ diff --git a/corpus/exif/exif_encoding_crash.jpg b/corpus/exif/exif_encoding_crash.jpg new file mode 100644 index 0000000..55138ab Binary files /dev/null and b/corpus/exif/exif_encoding_crash.jpg differ diff --git a/corpus/exif/image007.jpg b/corpus/exif/image007.jpg new file mode 100644 index 0000000..8526540 Binary files /dev/null and b/corpus/exif/image007.jpg differ diff --git a/corpus/exif/image008.jpg b/corpus/exif/image008.jpg new file mode 100644 index 0000000..3e8bfe4 Binary files /dev/null and b/corpus/exif/image008.jpg differ diff --git a/corpus/exif/image009.jpg b/corpus/exif/image009.jpg new file mode 100644 index 0000000..8803ddc Binary files /dev/null and b/corpus/exif/image009.jpg differ diff --git a/corpus/exif/image010.jpg b/corpus/exif/image010.jpg new file mode 100644 index 0000000..31ed6d6 Binary files /dev/null and b/corpus/exif/image010.jpg differ diff --git a/corpus/exif/image011.jpg b/corpus/exif/image011.jpg new file mode 100644 index 0000000..fcd5783 Binary files /dev/null and b/corpus/exif/image011.jpg differ diff --git a/corpus/exif/image012.jpg b/corpus/exif/image012.jpg new file mode 100644 index 0000000..dd25e06 Binary files /dev/null and b/corpus/exif/image012.jpg differ diff --git a/corpus/exif/image013.jpg b/corpus/exif/image013.jpg new file mode 100644 index 0000000..93ded26 Binary files /dev/null and b/corpus/exif/image013.jpg differ diff --git a/corpus/exif/image014.jpg b/corpus/exif/image014.jpg new file mode 100644 index 0000000..7657a0a Binary files /dev/null and b/corpus/exif/image014.jpg differ diff --git a/corpus/exif/image015.jpg b/corpus/exif/image015.jpg new file mode 100644 index 0000000..6f52dec Binary files /dev/null and b/corpus/exif/image015.jpg differ diff --git a/corpus/exif/image016.tiff b/corpus/exif/image016.tiff new file mode 100644 index 0000000..1712113 Binary files /dev/null and b/corpus/exif/image016.tiff differ diff --git a/corpus/exif/image017.tiff b/corpus/exif/image017.tiff new file mode 100644 index 0000000..89800d8 Binary files /dev/null and b/corpus/exif/image017.tiff differ diff --git a/corpus/exif/image018.tiff b/corpus/exif/image018.tiff new file mode 100644 index 0000000..6b4492f Binary files /dev/null and b/corpus/exif/image018.tiff differ diff --git a/corpus/exif/image020.tiff b/corpus/exif/image020.tiff new file mode 100644 index 0000000..87f1878 Binary files /dev/null and b/corpus/exif/image020.tiff differ diff --git a/corpus/exif/image021.tiff b/corpus/exif/image021.tiff new file mode 100644 index 0000000..190f30b Binary files /dev/null and b/corpus/exif/image021.tiff differ diff --git a/corpus/exif/image022.tiff b/corpus/exif/image022.tiff new file mode 100644 index 0000000..88f4373 Binary files /dev/null and b/corpus/exif/image022.tiff differ diff --git a/corpus/exif/image023.tiff b/corpus/exif/image023.tiff new file mode 100644 index 0000000..dc33f6e Binary files /dev/null and b/corpus/exif/image023.tiff differ diff --git a/corpus/exif/image024.jpg b/corpus/exif/image024.jpg new file mode 100644 index 0000000..0b5a42e Binary files /dev/null and b/corpus/exif/image024.jpg differ diff --git a/corpus/exif/image025.jpg b/corpus/exif/image025.jpg new file mode 100644 index 0000000..a5c0e17 Binary files /dev/null and b/corpus/exif/image025.jpg differ diff --git a/corpus/exif/image026.tiff b/corpus/exif/image026.tiff new file mode 100644 index 0000000..8fdafc7 Binary files /dev/null and b/corpus/exif/image026.tiff differ diff --git a/corpus/exif/image027.tiff b/corpus/exif/image027.tiff new file mode 100644 index 0000000..7c3a37a Binary files /dev/null and b/corpus/exif/image027.tiff differ diff --git a/corpus/exif/test1.jpg b/corpus/exif/test1.jpg new file mode 100644 index 0000000..121decb Binary files /dev/null and b/corpus/exif/test1.jpg differ diff --git a/corpus/exif/test2.jpg b/corpus/exif/test2.jpg new file mode 100644 index 0000000..f60ecde Binary files /dev/null and b/corpus/exif/test2.jpg differ diff --git a/corpus/exif/test22.jpg b/corpus/exif/test22.jpg new file mode 100644 index 0000000..f60ecde Binary files /dev/null and b/corpus/exif/test22.jpg differ diff --git a/corpus/exif/test3.jpg b/corpus/exif/test3.jpg new file mode 100644 index 0000000..7547a16 Binary files /dev/null and b/corpus/exif/test3.jpg differ diff --git a/corpus/exif/test4.jpg b/corpus/exif/test4.jpg new file mode 100644 index 0000000..8a23a7b Binary files /dev/null and b/corpus/exif/test4.jpg differ diff --git a/corpus/exif/test5.jpg b/corpus/exif/test5.jpg new file mode 100644 index 0000000..d03cac1 Binary files /dev/null and b/corpus/exif/test5.jpg differ diff --git a/corpus/exif/test6.jpg b/corpus/exif/test6.jpg new file mode 100644 index 0000000..073cefd Binary files /dev/null and b/corpus/exif/test6.jpg differ diff --git a/fuzzer-exif.c b/fuzzer-exif.c new file mode 100644 index 0000000..296f9fc --- /dev/null +++ b/fuzzer-exif.c @@ -0,0 +1,87 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 2017, Johannes Schlüter <johannes@schlueters.de> | + | All rights reserved. | + +----------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions which are | + | bundled with this package in the file LICENSE. | + | This product includes PHP software, freely available from | + | <http://www.php.net/software/> | + +----------------------------------------------------------------------+ +*/ + +#include "fuzzer.h" + +#include "Zend/zend.h" +#include "main/php_config.h" +#include "main/php_main.h" +#include "ext/standard/php_var.h" + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include "fuzzer-sapi.h" + +int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + char *filename; + int filedes, result; + zend_fcall_info fci = {0}; + zend_fcall_info_cache fci_cache = {0}; + zval args[1], retval, func; + + if (php_request_startup()==FAILURE) { + php_module_shutdown(); + return 0; + } + + /* put the data in a file */ + filename = tmpnam(NULL); + filedes = open(filename, O_CREAT|O_RDWR); + write(filedes, Data, Size); + close(filedes); + + ZVAL_STRING(&func, "exif_read_data"); + + zend_fcall_info_init(&func, 0, &fci, &fci_cache, NULL, NULL); + + ZVAL_STRING(&args[0], filename); + fci.retval = &retval; + fci.param_count = 1; + fci.params = args; + fci.no_separation = 0; + + result = zend_call_function(&fci, &fci_cache); + /* to ensure retval is not broken */ + php_var_dump(&retval, 0); + + /* cleanup */ + ZVAL_UNDEF(&retval); + ZVAL_UNDEF(&args[0]); + ZVAL_UNDEF(&func); + unlink(filename); + php_request_shutdown(NULL); + + return 0; +} + +int LLVMFuzzerInitialize(int *argc, char ***argv) { + fuzzer_init_php(); + + /* fuzzer_shutdown_php(); */ + return 0; +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ +