]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - fuzz/libFuzzerLocal.c
2 * Copyright (C) 2017 Tobias Brunner
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 extern int LLVMFuzzerTestOneInput(const unsigned char *data
, size_t size
);
22 __attribute__((weak
)) extern int LLVMFuzzerInitialize(int *argc
, char ***argv
);
25 * This is a simple driver for the fuzz targets to verify test inputs outside
28 * Failures will usually cause crashes.
30 int main(int argc
, char **argv
)
35 fprintf(stderr
, "%s: running %d inputs\n", argv
[0], argc
- 1);
36 if (LLVMFuzzerInitialize
)
38 LLVMFuzzerInitialize(&argc
, &argv
);
40 for (i
= 1; i
< argc
; i
++)
42 fprintf(stderr
, "running: %s\n", argv
[i
]);
43 data
= chunk_map(argv
[i
], FALSE
);
46 fprintf(stderr
, "opening %s failed: %s\n", argv
[i
], strerror(errno
));
49 res
= LLVMFuzzerTestOneInput(data
->ptr
, data
->len
);
50 fprintf(stderr
, "done: %s: (%zd bytes)\n", argv
[i
], data
->len
);
57 fprintf(stderr
, "%s: completed %d inputs\n", argv
[0], i
-1);