php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
fuzzer-exif.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Stanislav Malyshev <stas@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17#include "fuzzer.h"
18
19#include "Zend/zend.h"
20#include <main/php_config.h>
21#include "main/php_main.h"
23
24#include <stdio.h>
25#include <stdint.h>
26#include <stdlib.h>
27#include <sys/types.h>
28#include <sys/stat.h>
29#include <fcntl.h>
30
31#include "fuzzer-sapi.h"
32
33int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
34#ifdef HAVE_EXIF
35 php_stream *stream;
36 zval stream_zv;
37
38 if (Size > 256 * 1024) {
39 /* Large inputs have a large impact on fuzzer performance,
40 * but are unlikely to be necessary to reach new codepaths. */
41 return 0;
42 }
43
45 return 0;
46 }
47
49 php_stream_write(stream, (const char *) Data, Size);
50 php_stream_to_zval(stream, &stream_zv);
51
52 fuzzer_call_php_func_zval("exif_read_data", 1, &stream_zv);
53
54 zval_ptr_dtor(&stream_zv);
55
56 /* cleanup */
58
59 return 0;
60#else
61 fprintf(stderr, "\n\nERROR:\nPHP built without EXIF, recompile with --enable-exif to use this fuzzer\n");
62 exit(1);
63#endif
64}
65
66int LLVMFuzzerInitialize(int *argc, char ***argv) {
68
69 /* fuzzer_shutdown_php(); */
70 return 0;
71}
72
fprintf($stream, string $format, mixed ... $values)
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition fuzzer-exif.c:33
int LLVMFuzzerInitialize(int *argc, char ***argv)
Definition fuzzer-exif.c:66
int fuzzer_request_startup(void)
void fuzzer_call_php_func_zval(const char *func_name, int nargs, zval *args)
int fuzzer_init_php(const char *extra_ini)
#define NULL
Definition gdcache.h:45
void php_request_shutdown(void *dummy)
Definition main.c:1885
#define TEMP_STREAM_DEFAULT
#define php_stream_memory_create(mode)
struct _php_stream php_stream
Definition php_streams.h:96
#define php_stream_to_zval(stream, zval)
#define php_stream_write(stream, buf, count)
struct _zval_struct zval
exit(string|int $status=0)
@ FAILURE
Definition zend_types.h:61
ZEND_API void zval_ptr_dtor(zval *zval_ptr)