Avoid core dump when ai_canonname is NULL.
(Now this happens for numeric addrs, as getaddrinfo() 1.3 -> 1.4 change) Reviewed by: Mark Huizer <xaa@timewasters.nl>
This commit is contained in:
parent
623136a74f
commit
01d81a0351
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56682
@ -122,8 +122,10 @@ realhostname_sa(char *host, size_t hsize, struct sockaddr *addr, int addrlen)
|
||||
port = ((struct sockinet *)addr)->si_port;
|
||||
((struct sockinet *)addr)->si_port = 0;
|
||||
if (!memcmp(sa, addr, sa->sa_len)) {
|
||||
strncpy(host, res->ai_canonname,
|
||||
hsize);
|
||||
if (res->ai_canonname != 0)
|
||||
strncpy(host,
|
||||
res->ai_canonname,
|
||||
hsize);
|
||||
result = HOSTNAME_FOUND;
|
||||
((struct sockinet *)addr)->si_port =
|
||||
port;
|
||||
@ -146,8 +148,10 @@ realhostname_sa(char *host, size_t hsize, struct sockaddr *addr, int addrlen)
|
||||
if (IN6_IS_ADDR_V4MAPPED(in6) &&
|
||||
!memcmp(&in6->s6_addr[12], in,
|
||||
sizeof(*in))) {
|
||||
strncpy(host, res->ai_canonname,
|
||||
hsize);
|
||||
if (res->ai_canonname != 0)
|
||||
strncpy(host,
|
||||
res->ai_canonname,
|
||||
hsize);
|
||||
result = HOSTNAME_FOUND;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user