Remove the rudimentary fuzzing since no one uses it anyway

This commit is contained in:
def 2020-09-05 23:50:31 +02:00
parent 4c74efd93f
commit b7da058b76
3 changed files with 0 additions and 53 deletions

View file

@ -68,12 +68,6 @@
extern "C" { extern "C" {
#endif #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_stdin() { return (IOHANDLE)stdin; }
IOHANDLE io_stdout() { return (IOHANDLE)stdout; } IOHANDLE io_stdout() { return (IOHANDLE)stdout; }
IOHANDLE io_stderr() { return (IOHANDLE)stderr; } IOHANDLE io_stderr() { return (IOHANDLE)stderr; }
@ -1475,21 +1469,12 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
/* set non-blocking */ /* set non-blocking */
net_set_non_blocking(sock); 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 */
return sock; return sock;
} }
int net_udp_send(NETSOCKET sock, const NETADDR *addr, const void *data, int size) int net_udp_send(NETSOCKET sock, const NETADDR *addr, const void *data, int size)
{ {
#ifndef FUZZING
int d = -1; int d = -1;
if(addr->type&NETTYPE_IPV4) 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_bytes += size;
network_stats.sent_packets++; network_stats.sent_packets++;
return d; return d;
#else
return size;
#endif /* FUZZING */
} }
void net_init_mmsgs(MMSGS* m) 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) int net_udp_recv(NETSOCKET sock, NETADDR *addr, void *buffer, int maxsize, MMSGS* m, unsigned char **data)
{ {
#ifndef FUZZING
char sockaddrbuf[128]; char sockaddrbuf[128];
int bytes = 0; int bytes = 0;
@ -1663,34 +1644,6 @@ int net_udp_recv(NETSOCKET sock, NETADDR *addr, void *buffer, int maxsize, MMSGS
else if(bytes == 0) else if(bytes == 0)
return 0; return 0;
return -1; /* error */ 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) int net_udp_close(NETSOCKET sock)

View file

@ -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); 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 // check if the compression was enabled, successful and good enough
#ifndef FUZZING
if(!NoCompress && CompressedSize > 0 && CompressedSize < pPacket->m_DataSize) if(!NoCompress && CompressedSize > 0 && CompressedSize < pPacket->m_DataSize)
{ {
FinalSize = CompressedSize; FinalSize = CompressedSize;
pPacket->m_Flags |= NET_PACKETFLAG_COMPRESSION; pPacket->m_Flags |= NET_PACKETFLAG_COMPRESSION;
} }
else else
#endif
{ {
// use uncompressed data // use uncompressed data
FinalSize = pPacket->m_DataSize; FinalSize = pPacket->m_DataSize;
@ -430,7 +428,5 @@ static const unsigned gs_aFreqTable[256+1] = {
void CNetBase::Init() void CNetBase::Init()
{ {
#ifndef FUZZING
ms_Huffman.Init(gs_aFreqTable); ms_Huffman.Init(gs_aFreqTable);
#endif
} }

View file

@ -318,10 +318,8 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
{ {
if(CtrlMsg == NET_CTRLMSG_CONNECT) if(CtrlMsg == NET_CTRLMSG_CONNECT)
{ {
#ifndef FUZZING
if(net_addr_comp_noport(&m_PeerAddr, pAddr) == 0 && time_get() - m_LastUpdateTime < time_freq() * 3) if(net_addr_comp_noport(&m_PeerAddr, pAddr) == 0 && time_get() - m_LastUpdateTime < time_freq() * 3)
return 0; return 0;
#endif
// send response and init connection // send response and init connection
Reset(); Reset();