mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
Remove the rudimentary fuzzing since no one uses it anyway
This commit is contained in:
parent
4c74efd93f
commit
b7da058b76
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue