Line | Count | Source |
1 | | // Copyright 2026 Google LLC |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | // |
15 | | //////////////////////////////////////////////////////////////////////////////// |
16 | | |
17 | | #define _GNU_SOURCE |
18 | | #include <sys/types.h> |
19 | | #include <sys/socket.h> |
20 | | #include <netinet/in.h> |
21 | | #include <netinet/ip6.h> |
22 | | #include <stdint.h> |
23 | | #include <stdio.h> |
24 | | #include <stdlib.h> |
25 | | #include <unistd.h> |
26 | | #include "radvd.h" |
27 | | |
28 | | // Mock functions needed for linking |
29 | | int sock = -1; |
30 | | |
31 | | // radvd.h declares these, but we might need to define them if we don't link radvd.o |
32 | | // However, we will link against objects that might need them. |
33 | | |
34 | | int LL_DEBUG_LOG = 0; |
35 | | int log_method = L_STDERR; |
36 | | char *conf_file = NULL; |
37 | | char *pname = "fuzz_config"; |
38 | | |
39 | | // We need to mock logging functions to avoid cluttering output |
40 | 6.39k | void dlog(int level, int flevel, char const *fmt, ...) {} |
41 | 19.9k | void flog(int level, char const *fmt, ...) {} |
42 | 0 | void set_debuglevel(int level) {} |
43 | 0 | int get_debuglevel(void) { return 0; } |
44 | | |
45 | | // We need readin_config |
46 | | struct Interface *readin_config(char const *path); |
47 | | |
48 | 566 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
49 | 566 | char filename[] = "/tmp/fuzz-config-XXXXXX"; |
50 | 566 | int fd = mkstemp(filename); |
51 | 566 | if (fd < 0) { |
52 | 0 | return 0; |
53 | 0 | } |
54 | 566 | write(fd, data, size); |
55 | 566 | close(fd); |
56 | | |
57 | 566 | struct Interface *ifaces = readin_config(filename); |
58 | | |
59 | 566 | if (ifaces) { |
60 | 0 | free_ifaces(ifaces); |
61 | 0 | } |
62 | | |
63 | 566 | unlink(filename); |
64 | 566 | return 0; |
65 | 566 | } |