]> git.ipfire.org Git - thirdparty/openssl.git/blob - fuzz/test-corpus.c
conf fuzzer: also check for an empty file
[thirdparty/openssl.git] / fuzz / test-corpus.c
1 /*
2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL licenses, (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.openssl.org/source/license.html
8 * or in the file LICENSE in the source distribution.
9 */
10
11 /*
12 * Given a list of files, run each of them through the fuzzer. Note that
13 * failure will be indicated by some kind of crash. Switching on things like
14 * asan improves the test.
15 */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <sys/stat.h>
20 #include <openssl/crypto.h>
21 #include "fuzzer.h"
22
23 int main(int argc, char **argv) {
24 int n;
25
26 FuzzerInitialize(&argc, &argv);
27
28 for (n = 1; n < argc; ++n) {
29 struct stat st;
30 FILE *f;
31 unsigned char *buf;
32 size_t s;
33
34 stat(argv[n], &st);
35 f = fopen(argv[n], "rb");
36 if (f == NULL)
37 continue;
38 buf = malloc(st.st_size);
39 s = fread(buf, 1, st.st_size, f);
40 OPENSSL_assert(s == (size_t)st.st_size);
41 FuzzerTestOneInput(buf, s);
42 free(buf);
43 fclose(f);
44 }
45 return 0;
46 }