php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
fuzzer-json.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: Johannes Schlüter <johanes@php.net> |
14 | Stanislav Malyshev <stas@php.net> |
15 +----------------------------------------------------------------------+
16 */
17
18#include "fuzzer.h"
19
20#include "Zend/zend.h"
21#include <main/php_config.h>
22#include "main/php_main.h"
23
24#include <stdio.h>
25#include <stdint.h>
26#include <stdlib.h>
27
28#include "fuzzer-sapi.h"
30
31int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
32
34 return 0;
35 }
36
37 char *data = malloc(Size + 1);
38 memcpy(data, Data, Size);
39 data[Size] = '\0';
40
41 for (int option = 0; option <=1; ++option) {
43 php_json_parser parser;
44 php_json_parser_init(&parser, &result, data, Size, option, 10);
45 if (php_json_yyparse(&parser) == SUCCESS) {
47 }
48 }
49
51
52 free(data);
53 return 0;
54}
55
56int LLVMFuzzerInitialize(int *argc, char ***argv) {
58
59 /* fuzzer_shutdown_php(); */
60 return 0;
61}
memcpy(ptr1, ptr2, size)
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition fuzzer-json.c:31
int LLVMFuzzerInitialize(int *argc, char ***argv)
Definition fuzzer-json.c:56
int fuzzer_request_startup(void)
int fuzzer_init_php(const char *extra_ini)
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
void php_request_shutdown(void *dummy)
Definition main.c:1885
struct _php_json_parser php_json_parser
PHP_JSON_API void php_json_parser_init(php_json_parser *parser, zval *return_value, const char *str, size_t str_len, int options, int max_depth)
int php_json_yyparse(php_json_parser *parser)
zend_constant * data
struct _zval_struct zval
@ FAILURE
Definition zend_types.h:61
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
bool result