Debian Codegraph @

fuzz/fuzzer.h

raw
1 /*
2 * Copyright (c) 2017-2024 Free Software Foundation, Inc.
3 *
4 * This file is part of GNU Wget.
5 *
6 * GNU Wget is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GNU Wget is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Wget. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include <stddef.h> // size_t
21 #include <stdint.h> // uint8_t
22
23 #if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
24 #pragma GCC diagnostic ignored "-Wunused"
25 #pragma GCC diagnostic ignored "-Wunused-parameter"
26 #pragma GCC diagnostic ignored "-Wpedantic"
27 #endif
28
29 #define CLOSE_STDERR \
30 int bak = dup(STDERR_FILENO); \
31 int fd = open("/dev/null", O_WRONLY); \
32 dup2(fd, STDERR_FILENO); \
33 close(fd);
34
35 #define RESTORE_STDERR \
36 dup2(bak, STDERR_FILENO); \
37 close(bak);
38
39 #ifdef __cplusplus
40 extern "C"
41 #endif
42 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);