Closed PR #3 Fixed a potential stack overflow

master
KoynovStas 7 years ago
parent 46ba07be85
commit 486c119281

@ -128,10 +128,8 @@ int get_ip_of_host(const char *host_name, int af, char *IP)
*
* in: if_name - network interface name in a string format of such "eth0"
* af - valid address types are AF_INET and AF_INET6
addr - a pointer to the structure of the address,
* which will be copied to the host address.
* This format is an IP address is necessary
* in functions such as connect()
* addr - a pointer to the structure of the in_addr or in6_addr,
* which the host address will be copied to.
*
* ret: 0 - success
* -1 - failure (see errno)
@ -180,12 +178,12 @@ int get_addr_of_if(const char *if_name, int af, void *addr)
if( af == AF_INET6)
{
addr_len = sizeof(struct sockaddr_in6);
addr_len = sizeof(struct in6_addr);
src = &(((struct sockaddr_in6 *)ifa_cur->ifa_addr)->sin6_addr);
}
else
{
addr_len = sizeof(struct sockaddr_in);
addr_len = sizeof(struct in_addr);
src = &(((struct sockaddr_in *)ifa_cur->ifa_addr)->sin_addr);
}

Loading…
Cancel
Save