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
"
29
#include "
ext/json/php_json_parser.h
"
30
31
int
LLVMFuzzerTestOneInput
(
const
uint8_t *Data,
size_t
Size) {
32
33
if
(
fuzzer_request_startup
() ==
FAILURE
){
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) {
42
zval
result
;
43
php_json_parser
parser;
44
php_json_parser_init
(&parser, &
result
,
data
, Size, option, 10);
45
if
(
php_json_yyparse
(&parser) ==
SUCCESS
) {
46
zval_ptr_dtor
(&
result
);
47
}
48
}
49
50
php_request_shutdown
(
NULL
);
51
52
free(
data
);
53
return
0;
54
}
55
56
int
LLVMFuzzerInitialize
(
int
*argc,
char
***argv) {
57
fuzzer_init_php
(
NULL
);
58
59
/* fuzzer_shutdown_php(); */
60
return
0;
61
}
memcpy
memcpy(ptr1, ptr2, size)
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition
fuzzer-json.c:31
LLVMFuzzerInitialize
int LLVMFuzzerInitialize(int *argc, char ***argv)
Definition
fuzzer-json.c:56
fuzzer_request_startup
int fuzzer_request_startup(void)
Definition
fuzzer-sapi.c:173
fuzzer_init_php
int fuzzer_init_php(const char *extra_ini)
Definition
fuzzer-sapi.c:131
fuzzer-sapi.h
fuzzer.h
NULL
#define NULL
Definition
gdcache.h:45
SUCCESS
#define SUCCESS
Definition
hash_sha3.c:261
php_request_shutdown
void php_request_shutdown(void *dummy)
Definition
main.c:1885
php_json_parser.h
php_json_parser
struct _php_json_parser php_json_parser
Definition
php_json_parser.h:23
php_json_parser_init
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)
php_json_yyparse
int php_json_yyparse(php_json_parser *parser)
php_main.h
data
zend_constant * data
Definition
phpdbg_info.c:102
zend.h
zval
struct _zval_struct zval
Definition
zend_builtin_functions.h:25
FAILURE
@ FAILURE
Definition
zend_types.h:61
zval_ptr_dtor
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
Definition
zend_variables.c:82
result
bool result
Definition
zend_vm_def.h:455
sapi
fuzzer
fuzzer-json.c
Generated on Sat Aug 23 2025 01:46:13 for php-internal-docs by
1.13.2