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 | // Make sure LLVMFuzzerInitialize is called. |
| 5 | #include <assert.h> |
| 6 | #include <stddef.h> |
| 7 | #include <stdint.h> |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | #include <string.h> |
| 11 | |
| 12 | static char *argv0; |
| 13 | |
| 14 | extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { |
| 15 | assert(*argc > 0); |
| 16 | argv0 = **argv; |
| 17 | fprintf(stderr, "LLVMFuzzerInitialize: %s\n", argv0); |
| 18 | return 0; |
| 19 | } |
| 20 | |
| 21 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
Kostya Serebryany | d3e4b7e | 2017-08-25 19:29:47 +0000 | [diff] [blame] | 22 | assert(argv0); |
George Karpenkov | 10ab2ac | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 23 | if (Size == strlen(argv0) && |
| 24 | !memmem(Data, Size, argv0, Size)) { |
| 25 | fprintf(stderr, "BINGO %s\n", argv0); |
| 26 | exit(1); |
| 27 | } |
| 28 | return 0; |
| 29 | } |