summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/fuzz-ndisc-rs.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-09-04 10:38:10 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-09-04 14:54:51 +0200
commit690afe79dd7612910abc6ac6d1fb247ed4db72b0 (patch)
treec978bedf2cbdefb521235786eb517c9ed33d4468 /src/libsystemd-network/fuzz-ndisc-rs.c
parenticmp6-util: make icmp6_receive() accept the null source address (diff)
downloadsystemd-690afe79dd7612910abc6ac6d1fb247ed4db72b0.tar.xz
systemd-690afe79dd7612910abc6ac6d1fb247ed4db72b0.zip
test: extract dummy icmp6 utils for tests
This extracts common implementation of dummy icmp6 utils used by tests.
Diffstat (limited to 'src/libsystemd-network/fuzz-ndisc-rs.c')
-rw-r--r--src/libsystemd-network/fuzz-ndisc-rs.c42
1 files changed, 1 insertions, 41 deletions
diff --git a/src/libsystemd-network/fuzz-ndisc-rs.c b/src/libsystemd-network/fuzz-ndisc-rs.c
index ef5567329e..54dbfc1c76 100644
--- a/src/libsystemd-network/fuzz-ndisc-rs.c
+++ b/src/libsystemd-network/fuzz-ndisc-rs.c
@@ -9,50 +9,10 @@
#include "alloc-util.h"
#include "fd-util.h"
#include "fuzz.h"
-#include "icmp6-util.h"
+#include "icmp6-util-unix.h"
#include "ndisc-internal.h"
#include "socket-util.h"
-static int test_fd[2] = PIPE_EBADF;
-
-int icmp6_bind_router_solicitation(int index) {
- assert_se(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) >= 0);
- return test_fd[0];
-}
-
-int icmp6_bind_router_advertisement(int index) {
- return -ENOSYS;
-}
-
-static struct in6_addr dummy_link_local = {
- .s6_addr = {
- 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x12, 0x34, 0x56, 0xff, 0xfe, 0x78, 0x9a, 0xbc,
- },
-};
-
-int icmp6_receive(
- int fd,
- void *iov_base,
- size_t iov_len,
- struct in6_addr *ret_sender,
- triple_timestamp *ret_timestamp) {
-
- assert_se(read(fd, iov_base, iov_len) == (ssize_t) iov_len);
-
- if (ret_timestamp)
- triple_timestamp_get(ret_timestamp);
-
- if (ret_sender)
- *ret_sender = dummy_link_local;
-
- return 0;
-}
-
-int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) {
- return 0;
-}
-
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
struct ether_addr mac_addr = {
.ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'}