1 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
2 | // See https://llvm.org/LICENSE.txt for license information. |
3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
4 | |
5 | // Source code for a simple DSO. |
6 | |
7 | #include <cstdint> |
8 | #include <cstdio> |
9 | #include <cstdlib> |
10 | #include <cstring> |
11 | extern int DSO1(int a); |
12 | extern int DSO2(int a); |
13 | extern int (int a); |
14 | |
15 | static volatile int *nil = 0; |
16 | |
17 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
18 | int x, y, z; |
19 | if (Size < sizeof(int) * 3) { |
20 | x = y = z = 0; |
21 | } else { |
22 | memcpy(dest: &x, src: Data + 0 * sizeof(int), n: sizeof(int)); |
23 | memcpy(dest: &y, src: Data + 1 * sizeof(int), n: sizeof(int)); |
24 | memcpy(dest: &z, src: Data + 2 * sizeof(int), n: sizeof(int)); |
25 | } |
26 | int sum = DSO1(a: x) + DSO2(a: y) + (z ? DSOTestExtra(a: z) : 0); |
27 | if (sum == 3) { |
28 | fprintf(stderr, format: "BINGO %d %d %d\n" , x, y, z); |
29 | *nil = 0; |
30 | } |
31 | return 0; |
32 | } |
33 | |