Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:p_conrad
tla
tla-1.3.5-getaddrinfo.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File tla-1.3.5-getaddrinfo.patch of Package tla
--- tla-1.3.5.orig/src/hackerlab/vu-network/url-socket.c 2006-07-20 08:34:36.000000000 +0200 +++ tla-1.3.5/src/hackerlab/vu-network/url-socket.c 2010-12-17 14:38:01.000000000 +0100 @@ -1186,11 +1186,18 @@ } else { - struct hostent * hostentp; - hostentp = gethostbyname (host); - if (!hostentp || (hostentp->h_addrtype != AF_INET)) + struct addrinfo *ai = NULL, + hints = {0, AF_INET, SOCK_STREAM, 0, 0, NULL, NULL, NULL}; + int res = getaddrinfo(host, NULL, &hints, &ai); + if(res != 0) { goto bogus_addr; - mem_move ((t_uchar *)&IN_ADDR(addr)->sin_addr, hostentp->h_addr, hostentp->h_length); + } + if (ai->ai_family != AF_INET || ai->ai_addrlen != 4) { + freeaddrinfo(ai); + goto bogus_addr; + } + mem_move ((t_uchar *)&IN_ADDR(addr)->sin_addr, (t_uchar *) &(((struct sockaddr_in *) ai->ai_addr)->sin_addr), ai->ai_addrlen); + freeaddrinfo(ai); } *addr_len = sizeof (struct sockaddr_in); } @@ -1306,12 +1313,18 @@ } else { - struct hostent * hostentp; - - hostentp = gethostbyname (host); - if (!hostentp || (hostentp->h_addrtype != AF_INET)) + struct addrinfo *ai = NULL, + hints = {0, AF_INET, SOCK_STREAM, 0, 0, NULL, NULL, NULL}; + int res = getaddrinfo(host, NULL, &hints, &ai); + if(res != 0) { goto bogus_addr; - mem_move ((t_uchar *)&host_addr, hostentp->h_addr, hostentp->h_length); + } + if (ai->ai_family != AF_INET || ai->ai_addrlen != 4) { + freeaddrinfo(ai); + goto bogus_addr; + } + mem_move ((t_uchar *)&host_addr, (t_uchar *) &(((struct sockaddr_in *) ai->ai_addr)->sin_addr), ai->ai_addrlen); + freeaddrinfo(ai); host_addr = ntohl (host_addr); } @@ -1451,16 +1464,22 @@ } else { - struct hostent * hostentp; - - hostentp = gethostbyname (host); - if (!hostentp || (hostentp->h_addrtype != AF_INET)) - { + struct addrinfo *ai = NULL, + hints = {AI_PASSIVE, AF_INET, SOCK_STREAM, 0, 0, NULL, NULL, NULL}; + int res = getaddrinfo(host, NULL, &hints, &ai); + if(res != 0) { bogus_addr: *errn = EINVAL; return -1; - } - mem_move ((t_uchar *)&addr.sin_addr, hostentp->h_addr, hostentp->h_length); + } + if (ai->ai_family != AF_INET || ai->ai_addrlen != 4) { + freeaddrinfo(ai); + goto bogus_addr; + } + mem_move ((t_uchar *)&addr.sin_addr, + (t_uchar *) &(((struct sockaddr_in *) ai->ai_addr)->sin_addr), + ai->ai_addrlen); + freeaddrinfo(ai); } } @@ -1508,20 +1527,29 @@ my_name = must_realloc (my_name, size + 1); } - hostent = gethostbyname (my_name); - if (!hostent) - { + struct addrinfo *ai = NULL, + hints = {0, AF_INET, SOCK_STREAM, 0, 0, NULL, NULL, NULL}; + int res = getaddrinfo(my_name, NULL, &hints, &ai); + if(res != 0) { int ign; *errn = errno; vu_close (&ign, fd); return -1; - } + } + if (ai->ai_family != AF_INET || ai->ai_addrlen != 4) { + int ign; + freeaddrinfo(ai); + *errn = errno; + vu_close (&ign, fd); + return -1; + } { t_uint32 tmp; - mem_move ((t_uchar *)&tmp, (t_uchar *)hostent->h_addr, 4); + mem_move ((t_uchar *)&tmp, (t_uchar *) &(((struct sockaddr_in *) ai->ai_addr)->sin_addr), ai->ai_addrlen); *host_addr_is = ntohl (tmp); } + freeaddrinfo(ai); } }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor