From 81780e01c60d1a2531b5cbdf096f0487eb8e58b2 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Fri, 29 Nov 2024 17:11:48 +0100 Subject: [PATCH] test: remove unused fuzz mock --- test/CMakeLists.txt | 1 - test/mock/fuzz.c | 110 -------------------------------------------- test/test.h | 9 ---- 3 files changed, 120 deletions(-) delete mode 100644 test/mock/fuzz.c diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 439094661..62ccbb5f5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -102,7 +102,6 @@ set(SRCS md5.c mem.c mock/dnssrv.c - mock/fuzz.c mock/nat.c mock/pf.c mock/sipsrv.c diff --git a/test/mock/fuzz.c b/test/mock/fuzz.c deleted file mode 100644 index dd94a9e93..000000000 --- a/test/mock/fuzz.c +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @file mock/fuzz.c Packet fuzzing - * - * Copyright (C) 2010 Creytiv.com - */ -#include -#include -#include "test.h" - - -#define DEBUG_MODULE "mock/fuzz" -#define DEBUG_LEVEL 5 -#include - - -struct fuzz { - struct tcp_helper *th; - struct tcp_conn *tc; - size_t packet_count; -}; - - -static void destructor(void *data) -{ - struct fuzz *fuzz = data; - - mem_deref(fuzz->th); - mem_deref(fuzz->tc); -} - - -static void apply_fuzzing(struct fuzz *fuzz, struct mbuf *mb) -{ - const size_t len = mbuf_get_left(mb); - size_t pos; - bool flip; - unsigned bit; - - if (len == 0) - return; - - ++fuzz->packet_count; - - pos = rand_u16() % len; - bit = rand_u16() % 8; - - /* percent change of corrupt packet */ - flip = ((rand_u16() % 100) < 33); - - if (flip) { - re_printf("### flipped bit on pos %zu\n", pos); - - /* flip a random bit */ - mbuf_buf(mb)[pos] ^= 1<tc = mem_ref(tc); - - err = tcp_register_helper(&fuzz->th, tc, -1000, NULL, - helper_send_handler, - helper_recv_handler, fuzz); - if (err) - goto out; - - out: - if (err) - mem_deref(fuzz); - else - *fuzzp = fuzz; - - return err; -} diff --git a/test/test.h b/test/test.h index 303b84166..eaf278bd4 100644 --- a/test/test.h +++ b/test/test.h @@ -525,15 +525,6 @@ int sip_server_uri(struct sip_server *srv, char *uri, size_t sz, enum sip_transp tp); -/* - * Packet fuzzing - */ - -struct fuzz; - -int fuzz_register_tcpconn(struct fuzz **fuzzp, struct tcp_conn *tc); - - /* * Mock DNS-Server */