Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
George Karpenkov | 10ab2ac | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 4 | #include <stddef.h> |
| 5 | #include <stdint.h> |
| 6 | #include <stdio.h> |
| 7 | |
| 8 | // Test for libFuzzer's "equivalence" fuzzing, part B. |
| 9 | extern "C" void LLVMFuzzerAnnounceOutput(const uint8_t *Data, size_t Size); |
| 10 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 11 | // fprintf(stderr, "B %zd\n", Size); |
| 12 | uint8_t Result[50]; |
| 13 | if (Size > 50) Size = 50; |
| 14 | for (size_t i = 0; i < Size; i++) |
| 15 | Result[Size - i - 1] = Data[i]; |
| 16 | |
| 17 | // Be a bit different from EquivalenceATest |
| 18 | if (Size > 10 && Data[5] == 'B' && Data[6] == 'C' && Data[7] == 'D') { |
| 19 | static int c; |
| 20 | if (!c) |
| 21 | fprintf(stderr, "ZZZZZZZ\n"); |
| 22 | c = 1; |
| 23 | Result[2]++; |
| 24 | } |
| 25 | |
| 26 | LLVMFuzzerAnnounceOutput(Result, Size); |
| 27 | return 0; |
| 28 | } |