summaryrefslogtreecommitdiffstats
path: root/lib/libutil/realhostname.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libutil/realhostname.c')
-rw-r--r--lib/libutil/realhostname.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libutil/realhostname.c b/lib/libutil/realhostname.c
index 26bd5e6..7c409a8 100644
--- a/lib/libutil/realhostname.c
+++ b/lib/libutil/realhostname.c
@@ -52,7 +52,7 @@ struct sockinet {
int
realhostname(char *host, size_t hsize, const struct in_addr *ip)
{
- char trimmed[MAXHOSTNAMELEN+1];
+ char trimmed[MAXHOSTNAMELEN];
int result;
struct hostent *hp;
@@ -136,15 +136,15 @@ realhostname_sa(char *host, size_t hsize, struct sockaddr *addr, int addrlen)
freeaddrinfo(ores);
goto numeric;
}
- strncpy(buf, ores->ai_canonname,
+ strlcpy(buf, ores->ai_canonname,
sizeof(buf));
trimdomain(buf, hsize);
- strncpy(host, buf, hsize);
- if (strlen(host) > hsize &&
+ if (strlen(buf) > hsize &&
addr->sa_family == AF_INET) {
freeaddrinfo(ores);
goto numeric;
}
+ strncpy(host, buf, hsize);
break;
}
((struct sockinet *)addr)->si_port = port;
OpenPOWER on IntegriCloud