George Karpenkov | 10ab2ac | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 1 | // This file is distributed under the University of Illinois Open Source |
| 2 | // License. See LICENSE.TXT for details. |
| 3 | |
| 4 | // Test that libFuzzer itself does not read out of bounds. |
| 5 | #include <assert.h> |
| 6 | #include <cstddef> |
| 7 | #include <cstdint> |
| 8 | #include <cstdlib> |
| 9 | #include <cstring> |
| 10 | #include <iostream> |
| 11 | |
| 12 | static volatile int Sink; |
| 13 | |
| 14 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 15 | if (Size < 5) return 0; |
| 16 | const char *Ch = reinterpret_cast<const char *>(Data); |
| 17 | if (Ch[Size - 3] == 'a') |
| 18 | Sink = strncmp(Ch + Size - 3, "abcdefg", 6); |
| 19 | return 0; |
| 20 | } |
| 21 | |