Fixed major denial of service issue.

This commit is contained in:
irungentoo 2014-05-08 18:07:51 -04:00
parent 52bfd7cd55
commit 89022326d3
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98

View File

@ -297,7 +297,6 @@ int sendpacket(Networking_Core *net, IP_Port ip_port, uint8_t *data, uint32_t le
* ip and port of sender is put into ip_port. * ip and port of sender is put into ip_port.
* Packet data is put into data. * Packet data is put into data.
* Packet length is put into length. * Packet length is put into length.
* Dump all empty packets.
*/ */
static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t *length) static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t *length)
{ {
@ -311,7 +310,7 @@ static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t
*length = 0; *length = 0;
int fail_or_len = recvfrom(sock, (char *) data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen); int fail_or_len = recvfrom(sock, (char *) data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen);
if (fail_or_len <= 0) { if (fail_or_len < 0) {
#ifdef LOGGING #ifdef LOGGING
if ((fail_or_len < 0) && (errno != EWOULDBLOCK)) { if ((fail_or_len < 0) && (errno != EWOULDBLOCK)) {
@ -320,7 +319,7 @@ static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t
} }
#endif #endif
return -1; /* Nothing received or empty packet. */ return -1; /* Nothing received. */
} }
*length = (uint32_t)fail_or_len; *length = (uint32_t)fail_or_len;