fix: bad memset length in ip_init()

This commit is contained in:
Coren[m] 2013-09-10 17:38:53 +02:00
parent bcb283cf45
commit f267266bf6

View File

@ -307,7 +307,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
fcntl(temp->sock, F_SETFL, O_NONBLOCK, 1); fcntl(temp->sock, F_SETFL, O_NONBLOCK, 1);
#endif #endif
/* Bind our socket to port PORT and address 0.0.0.0 */ /* Bind our socket to port PORT and the given IP address (usually 0.0.0.0 or ::) */
uint16_t *portptr = NULL; uint16_t *portptr = NULL;
struct sockaddr_storage addr; struct sockaddr_storage addr;
size_t addrsize; size_t addrsize;
@ -371,7 +371,8 @@ Networking_Core *new_networking(IP ip, uint16_t port)
*portptr = htons(port); *portptr = htons(port);
} }
printf("Failed to bind socket: %s (IP/Port: %s:%u\n", strerror(errno), ip_ntoa(&ip), port); fprintf(stderr, "Failed to bind socket: %u, %s (IP/Port: %s:%u\n", errno,
strerror(errno), ip_ntoa(&ip), port);
free(temp); free(temp);
return NULL; return NULL;
} }
@ -436,7 +437,7 @@ void ip_reset(IP *ip)
return; return;
#ifdef TOX_ENABLE_IPV6 #ifdef TOX_ENABLE_IPV6
memset(ip, 0, sizeof(*ip)); memset(ip, 0, sizeof(IP));
#else #else
ip->uint32 = 0; ip->uint32 = 0;
#endif #endif
@ -449,7 +450,7 @@ void ip_init(IP *ip, uint8_t ipv6enabled)
return; return;
#ifdef TOX_ENABLE_IPV6 #ifdef TOX_ENABLE_IPV6
memset(ip, 0, sizeof(ip)); memset(ip, 0, sizeof(IP));
ip->family = ipv6enabled ? AF_INET6 : AF_INET; ip->family = ipv6enabled ? AF_INET6 : AF_INET;
#else #else
ip->uint32 = 0; ip->uint32 = 0;