xref: /aosp_15_r20/external/bc/include/ossfuzz.h (revision 5a6e848804d15c18a0125914844ee4eb0bda4fcf)
1*5a6e8488SAndroid Build Coastguard Worker /*
2*5a6e8488SAndroid Build Coastguard Worker  * *****************************************************************************
3*5a6e8488SAndroid Build Coastguard Worker  *
4*5a6e8488SAndroid Build Coastguard Worker  * SPDX-License-Identifier: BSD-2-Clause
5*5a6e8488SAndroid Build Coastguard Worker  *
6*5a6e8488SAndroid Build Coastguard Worker  * Copyright (c) 2018-2024 Gavin D. Howard and contributors.
7*5a6e8488SAndroid Build Coastguard Worker  *
8*5a6e8488SAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
9*5a6e8488SAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions are met:
10*5a6e8488SAndroid Build Coastguard Worker  *
11*5a6e8488SAndroid Build Coastguard Worker  * * Redistributions of source code must retain the above copyright notice, this
12*5a6e8488SAndroid Build Coastguard Worker  *   list of conditions and the following disclaimer.
13*5a6e8488SAndroid Build Coastguard Worker  *
14*5a6e8488SAndroid Build Coastguard Worker  * * Redistributions in binary form must reproduce the above copyright notice,
15*5a6e8488SAndroid Build Coastguard Worker  *   this list of conditions and the following disclaimer in the documentation
16*5a6e8488SAndroid Build Coastguard Worker  *   and/or other materials provided with the distribution.
17*5a6e8488SAndroid Build Coastguard Worker  *
18*5a6e8488SAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*5a6e8488SAndroid Build Coastguard Worker  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*5a6e8488SAndroid Build Coastguard Worker  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*5a6e8488SAndroid Build Coastguard Worker  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*5a6e8488SAndroid Build Coastguard Worker  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*5a6e8488SAndroid Build Coastguard Worker  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*5a6e8488SAndroid Build Coastguard Worker  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*5a6e8488SAndroid Build Coastguard Worker  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*5a6e8488SAndroid Build Coastguard Worker  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*5a6e8488SAndroid Build Coastguard Worker  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*5a6e8488SAndroid Build Coastguard Worker  * POSSIBILITY OF SUCH DAMAGE.
29*5a6e8488SAndroid Build Coastguard Worker  *
30*5a6e8488SAndroid Build Coastguard Worker  * *****************************************************************************
31*5a6e8488SAndroid Build Coastguard Worker  *
32*5a6e8488SAndroid Build Coastguard Worker  * Declarations for the OSS-Fuzz build of bc and dc.
33*5a6e8488SAndroid Build Coastguard Worker  *
34*5a6e8488SAndroid Build Coastguard Worker  */
35*5a6e8488SAndroid Build Coastguard Worker 
36*5a6e8488SAndroid Build Coastguard Worker #include <stdint.h>
37*5a6e8488SAndroid Build Coastguard Worker #include <stdlib.h>
38*5a6e8488SAndroid Build Coastguard Worker 
39*5a6e8488SAndroid Build Coastguard Worker #ifndef BC_OSSFUZZ_H
40*5a6e8488SAndroid Build Coastguard Worker #define BC_OSSFUZZ_H
41*5a6e8488SAndroid Build Coastguard Worker 
42*5a6e8488SAndroid Build Coastguard Worker /// The number of args in fuzzer arguments, including the NULL terminator.
43*5a6e8488SAndroid Build Coastguard Worker extern const size_t bc_fuzzer_args_len;
44*5a6e8488SAndroid Build Coastguard Worker 
45*5a6e8488SAndroid Build Coastguard Worker /// The standard arguments for the bc fuzzer with the -c argument.
46*5a6e8488SAndroid Build Coastguard Worker extern const char* bc_fuzzer_args_c[];
47*5a6e8488SAndroid Build Coastguard Worker 
48*5a6e8488SAndroid Build Coastguard Worker /// The standard arguments for the bc fuzzer with the -C argument.
49*5a6e8488SAndroid Build Coastguard Worker extern const char* bc_fuzzer_args_C[];
50*5a6e8488SAndroid Build Coastguard Worker 
51*5a6e8488SAndroid Build Coastguard Worker /// The standard arguments for the dc fuzzer with the -c argument.
52*5a6e8488SAndroid Build Coastguard Worker extern const char* dc_fuzzer_args_c[];
53*5a6e8488SAndroid Build Coastguard Worker 
54*5a6e8488SAndroid Build Coastguard Worker /// The standard arguments for the dc fuzzer with the -C argument.
55*5a6e8488SAndroid Build Coastguard Worker extern const char* dc_fuzzer_args_C[];
56*5a6e8488SAndroid Build Coastguard Worker 
57*5a6e8488SAndroid Build Coastguard Worker /// The data pointer.
58*5a6e8488SAndroid Build Coastguard Worker extern uint8_t* bc_fuzzer_data;
59*5a6e8488SAndroid Build Coastguard Worker 
60*5a6e8488SAndroid Build Coastguard Worker /**
61*5a6e8488SAndroid Build Coastguard Worker  * The function that the fuzzer runs.
62*5a6e8488SAndroid Build Coastguard Worker  * @param Data  The data.
63*5a6e8488SAndroid Build Coastguard Worker  * @param Size  The number of bytes in @a Data.
64*5a6e8488SAndroid Build Coastguard Worker  * @return      0 on success, -1 on error.
65*5a6e8488SAndroid Build Coastguard Worker  * @pre         @a Data must not be equal to NULL if @a Size > 0.
66*5a6e8488SAndroid Build Coastguard Worker  */
67*5a6e8488SAndroid Build Coastguard Worker int
68*5a6e8488SAndroid Build Coastguard Worker LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
69*5a6e8488SAndroid Build Coastguard Worker 
70*5a6e8488SAndroid Build Coastguard Worker /**
71*5a6e8488SAndroid Build Coastguard Worker  * The initialization function for the fuzzer.
72*5a6e8488SAndroid Build Coastguard Worker  * @param argc  A pointer to the argument count.
73*5a6e8488SAndroid Build Coastguard Worker  * @param argv  A pointer to the argument list.
74*5a6e8488SAndroid Build Coastguard Worker  * @return      0 on success, -1 on error.
75*5a6e8488SAndroid Build Coastguard Worker  */
76*5a6e8488SAndroid Build Coastguard Worker int
77*5a6e8488SAndroid Build Coastguard Worker LLVMFuzzerInitialize(int* argc, char*** argv);
78*5a6e8488SAndroid Build Coastguard Worker 
79*5a6e8488SAndroid Build Coastguard Worker #endif // BC_OSSFUZZ_H
80