Kostya Serebryany | aca7696 | 2016-01-16 01:23:12 +0000 | [diff] [blame] | 1 | // Make sure LLVMFuzzerInitialize is called. |
| 2 | #include <assert.h> |
| 3 | #include <stddef.h> |
| 4 | #include <stdint.h> |
| 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> |
| 7 | #include <string.h> |
| 8 | |
| 9 | static char *argv0; |
| 10 | |
| 11 | extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { |
| 12 | assert(argc > 0); |
| 13 | argv0 = **argv; |
| 14 | return 0; |
| 15 | } |
| 16 | |
| 17 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 18 | if (strncmp(reinterpret_cast<const char*>(Data), argv0, Size)) { |
| 19 | fprintf(stderr, "BINGO\n"); |
| 20 | exit(1); |
| 21 | } |
| 22 | return 0; |
| 23 | } |