s3: libsmb: Cleanup in get_dc_list()
[Samba.git] / lib / fuzzing / afl-fuzz-main.c
blob9f6775578678f4222d19b23b8bf8c2d22335ea21
1 /*
2 Unix SMB/CIFS implementation.
4 Fuzz driver (AFL style)
6 Copyright (C) Andrew Bartlett 2019
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "lib/util/samba_util.h"
24 #include "fuzzing.h"
26 int main(int argc, char *argv[]) {
27 int ret;
28 size_t size = 0;
29 #ifdef __AFL_LOOP
30 while (__AFL_LOOP(1000))
31 #else
32 int i;
33 for (i = 0; i < argc; i++) {
34 uint8_t *buf = (uint8_t *)file_load(argv[i],
35 &size,
37 NULL);
38 ret = LLVMFuzzerTestOneInput(buf, size);
39 TALLOC_FREE(buf);
40 if (ret != 0) {
41 return ret;
44 if (i == 0)
45 #endif
47 uint8_t *buf = (uint8_t *)fd_load(0, &size, 0, NULL);
48 if (buf == NULL) {
49 exit(1);
52 ret = LLVMFuzzerTestOneInput(buf, size);
53 TALLOC_FREE(buf);
55 return ret;