From b7da058b76d904881e1ddd24f4f45577ca9927ff Mon Sep 17 00:00:00 2001 From: def Date: Sat, 5 Sep 2020 23:50:31 +0200 Subject: [PATCH] Remove the rudimentary fuzzing since no one uses it anyway --- src/base/system.c | 47 ------------------------------ src/engine/shared/network.cpp | 4 --- src/engine/shared/network_conn.cpp | 2 -- 3 files changed, 53 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index 8f398b542..abb9b20d8 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -68,12 +68,6 @@ extern "C" { #endif -#ifdef FUZZING -static unsigned char gs_NetData[1024]; -static int gs_NetPosition = 0; -static int gs_NetSize = 0; -#endif - IOHANDLE io_stdin() { return (IOHANDLE)stdin; } IOHANDLE io_stdout() { return (IOHANDLE)stdout; } IOHANDLE io_stderr() { return (IOHANDLE)stderr; } @@ -1475,21 +1469,12 @@ NETSOCKET net_udp_create(NETADDR bindaddr) /* set non-blocking */ net_set_non_blocking(sock); -#ifdef FUZZING - IOHANDLE file = io_open("bar.txt", IOFLAG_READ); - gs_NetPosition = 0; - gs_NetSize = io_length(file); - io_read(file, gs_NetData, 1024); - io_close(file); -#endif /* FUZZING */ - /* return */ return sock; } int net_udp_send(NETSOCKET sock, const NETADDR *addr, const void *data, int size) { -#ifndef FUZZING int d = -1; if(addr->type&NETTYPE_IPV4) @@ -1564,9 +1549,6 @@ int net_udp_send(NETSOCKET sock, const NETADDR *addr, const void *data, int size network_stats.sent_bytes += size; network_stats.sent_packets++; return d; -#else - return size; -#endif /* FUZZING */ } void net_init_mmsgs(MMSGS* m) @@ -1592,7 +1574,6 @@ void net_init_mmsgs(MMSGS* m) int net_udp_recv(NETSOCKET sock, NETADDR *addr, void *buffer, int maxsize, MMSGS* m, unsigned char **data) { -#ifndef FUZZING char sockaddrbuf[128]; int bytes = 0; @@ -1663,34 +1644,6 @@ int net_udp_recv(NETSOCKET sock, NETADDR *addr, void *buffer, int maxsize, MMSGS else if(bytes == 0) return 0; return -1; /* error */ -#else /* ifdef FUZZING */ - addr->type = NETTYPE_IPV4; - addr->port = 11111; - addr->ip[0] = 127; - addr->ip[1] = 0; - addr->ip[2] = 0; - addr->ip[3] = 1; - - int CurrentData = 0; - while (gs_NetPosition < gs_NetSize && CurrentData < maxsize) - { - if(gs_NetData[gs_NetPosition] == '\n') - { - gs_NetPosition++; - break; - } - - ((unsigned char*)buffer)[CurrentData] = gs_NetData[gs_NetPosition]; - *data = buffer; - CurrentData++; - gs_NetPosition++; - } - - if (gs_NetPosition >= gs_NetSize) - exit(0); - - return CurrentData; -#endif /* FUZZING */ } int net_udp_close(NETSOCKET sock) diff --git a/src/engine/shared/network.cpp b/src/engine/shared/network.cpp index 5bc0c2ed7..7f2f67338 100644 --- a/src/engine/shared/network.cpp +++ b/src/engine/shared/network.cpp @@ -145,14 +145,12 @@ void CNetBase::SendPacket(NETSOCKET Socket, NETADDR *pAddr, CNetPacketConstruct CompressedSize = ms_Huffman.Compress(pPacket->m_aChunkData, pPacket->m_DataSize, &aBuffer[HeaderSize], NET_MAX_PACKETSIZE-HeaderSize); // check if the compression was enabled, successful and good enough -#ifndef FUZZING if(!NoCompress && CompressedSize > 0 && CompressedSize < pPacket->m_DataSize) { FinalSize = CompressedSize; pPacket->m_Flags |= NET_PACKETFLAG_COMPRESSION; } else -#endif { // use uncompressed data FinalSize = pPacket->m_DataSize; @@ -430,7 +428,5 @@ static const unsigned gs_aFreqTable[256+1] = { void CNetBase::Init() { -#ifndef FUZZING ms_Huffman.Init(gs_aFreqTable); -#endif } diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index be553090a..2a6a65262 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -318,10 +318,8 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_ { if(CtrlMsg == NET_CTRLMSG_CONNECT) { -#ifndef FUZZING if(net_addr_comp_noport(&m_PeerAddr, pAddr) == 0 && time_get() - m_LastUpdateTime < time_freq() * 3) return 0; -#endif // send response and init connection Reset();