Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions sapi/fuzzer/fuzzer-exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
#ifdef HAVE_EXIF
php_stream *stream;
zval stream_zv;
zval args[4];

if (Size > 256 * 1024) {
/* Large inputs have a large impact on fuzzer performance,
Expand All @@ -45,11 +45,24 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {

stream = php_stream_memory_create(TEMP_STREAM_DEFAULT);
php_stream_write(stream, (const char *) Data, Size);
php_stream_to_zval(stream, &stream_zv);
php_stream_to_zval(stream, &args[0]);

fuzzer_call_php_func_zval("exif_read_data", 1, &stream_zv);
/* exif_read_data($stream, null, false, true): the thumbnail is only read if requested. */
ZVAL_NULL(&args[1]);
ZVAL_FALSE(&args[2]);
ZVAL_TRUE(&args[3]);
fuzzer_call_php_func_zval("exif_read_data", 4, args);

zval_ptr_dtor(&stream_zv);
/* exif_thumbnail($stream, $width, $height, $type): the thumbnail is only scanned for its
* dimensions if they are requested. */
for (int i = 1; i < 4; i++) {
ZVAL_NEW_EMPTY_REF(&args[i]);
ZVAL_NULL(Z_REFVAL(args[i]));
}
fuzzer_call_php_func_zval("exif_thumbnail", 4, args);
for (int i = 0; i < 4; i++) {
zval_ptr_dtor(&args[i]);
}

/* cleanup */
php_request_shutdown(NULL);
Expand Down
Loading