mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-25 18:12:57 +01:00
- do DNS lookup for symbolic names specified for a destination
or gateway. - improves error reporting using gai_strerror(3) instead of printing "bad value". - remove "0" for servname argument for getaddrinfo(3). Submitted by: Andreas Kohn <andreas __at__ syndrom23.de> MFC after: 1 week
This commit is contained in:
parent
2dc628b54a
commit
c60a8b32a2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=146546
@ -963,18 +963,19 @@ getaddr(which, s, hpp)
|
||||
case AF_INET6:
|
||||
{
|
||||
struct addrinfo hints, *res;
|
||||
int ecode;
|
||||
|
||||
q = NULL;
|
||||
if (which == RTA_DST && (q = strchr(s, '/')) != NULL)
|
||||
*q = '\0';
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = afamily; /*AF_INET6*/
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
|
||||
if (getaddrinfo(s, "0", &hints, &res) != 0 ||
|
||||
res->ai_family != AF_INET6 ||
|
||||
ecode = getaddrinfo(s, NULL, &hints, &res);
|
||||
if (ecode != 0 || res->ai_family != AF_INET6 ||
|
||||
res->ai_addrlen != sizeof(su->sin6)) {
|
||||
(void) fprintf(stderr, "%s: bad value\n", s);
|
||||
(void) fprintf(stderr, "%s: %s\n", s,
|
||||
gai_strerror(ecode));
|
||||
exit(1);
|
||||
}
|
||||
memcpy(&su->sin6, res->ai_addr, sizeof(su->sin6));
|
||||
|
Loading…
Reference in New Issue
Block a user