From 1837745d96f98827c0fb4f0db920cd29c20260c0 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 25 Jun 2013 17:16:45 -0400 Subject: Fixed one possible bug in the DHT and added a basic TODO list. Fixed a possible segfault which could have been cause by handling an empty packet. --- core/DHT.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'core/DHT.c') diff --git a/core/DHT.c b/core/DHT.c index 547520d2..ef04a391 100644 --- a/core/DHT.c +++ b/core/DHT.c @@ -15,14 +15,16 @@ int sendpacket(IP_Port ip_port, char * data, uint32_t length) //Function to recieve data, ip and port of sender is put into ip_port //the packet data into data //the packet length into length. +//dump all empty packets. int recievepacket(IP_Port * ip_port, char * data, uint32_t * length) { ADDR addr; uint32_t addrlen = sizeof(addr); (*(int *)length) = recvfrom(sock, data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen); - if(*(int *)length == -1) + if(*(int *)length <= 0) { //nothing recieved + //or empty packet return -1; } ip_port->ip = addr.ip; -- cgit v1.2.3