php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
fuzzer-mbregex.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
18#include "fuzzer.h"
19
20#include "Zend/zend.h"
21#include <main/php_config.h>
22#include "main/php_main.h"
23#include "oniguruma.h"
24
25#include <stdio.h>
26#include <stdint.h>
27#include <stdlib.h>
28
29#include "fuzzer-sapi.h"
30
31int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
32#ifdef HAVE_MBREGEX
33
35 return 0;
36 }
37
38 char *args[2];
39 char *data = malloc(Size+1);
40 memcpy(data, Data, Size);
41 data[Size] = '\0';
42
44
45 args[0] = data;
46 args[1] = "test123";
47 fuzzer_call_php_func("mb_ereg", 2, args);
48
49 args[0] = data;
50 args[1] = "test123";
51 fuzzer_call_php_func("mb_eregi", 2, args);
52
53 args[0] = data;
54 args[1] = data;
55 fuzzer_call_php_func("mb_ereg", 2, args);
56
57 args[0] = data;
58 args[1] = data;
59 fuzzer_call_php_func("mb_eregi", 2, args);
60
62
63 free(data);
64#else
65 fprintf(stderr, "\n\nERROR:\nPHP built without mbstring, recompile with --enable-mbstring to use this fuzzer\n");
66 exit(1);
67#endif
68 return 0;
69}
70
71int LLVMFuzzerInitialize(int *argc, char ***argv) {
73
74 /* The default parse depth limit allows stack overflows under asan. */
75 onig_set_parse_depth_limit(512);
76
77 /* fuzzer_shutdown_php(); */
78 return 0;
79}
fprintf($stream, string $format, mixed ... $values)
memcpy(ptr1, ptr2, size)
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
int LLVMFuzzerInitialize(int *argc, char ***argv)
int fuzzer_request_startup(void)
void fuzzer_call_php_func(const char *func_name, int nargs, char **params)
void fuzzer_setup_dummy_frame(void)
void fuzzer_request_shutdown(void)
int fuzzer_init_php(const char *extra_ini)
#define NULL
Definition gdcache.h:45
zend_constant * data
exit(string|int $status=0)
zval * args
@ FAILURE
Definition zend_types.h:61