Debian Codegraph @

tests/fuzzrunner.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 Sascha Brawer
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write see:
16 * <http://www.gnu.org/licenses/>.
17 */
18
19 #undef NDEBUG
20 #include "config.h"
21 #include "common.h"
22
23 #include <errno.h>
24 #include <stdint.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27
28 #include <espeak-ng/espeak_ng.h>
29
30 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
31
32 int main(int argc, char **argv) {
33 int i;
34
35 for (i = 1; i < argc; i++) {
36 size_t filesize = GetFileLength(argv[i]);
37 FILE *stream = fopen(argv[i], "r");
38 unsigned char *text = NULL;
39 if (stream == NULL) {
40 perror(argv[i]);
41 exit(EXIT_FAILURE);
42 }
43
44 text = (unsigned char *) malloc(filesize + 1);
45 if (text == NULL) {
46 espeak_ng_PrintStatusCodeMessage(ENOMEM, stderr, NULL);
47 exit(EXIT_FAILURE);
48 }
49
50 fread(text, 1, filesize, stream);
51 text[filesize] = 0;
52 fclose(stream);
53
54 LLVMFuzzerTestOneInput(text, filesize);
55 free(text);
56 }
57
58 return EXIT_SUCCESS;
59 }