summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2008-10-17 21:21:14 +0000
committerdelphij <delphij@FreeBSD.org>2008-10-17 21:21:14 +0000
commit767e2acdc70d46a3950466a91899ee6e591ec838 (patch)
tree12320fe97bf01eb2e86983f6662e0a61f3d8d27b /lib/libutil
parentcbecb62bfe4d08b1c22267fd67b968fa8d80de73 (diff)
downloadFreeBSD-src-767e2acdc70d46a3950466a91899ee6e591ec838.zip
FreeBSD-src-767e2acdc70d46a3950466a91899ee6e591ec838.tar.gz
Use strlcpy() when we mean it.
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/login_times.c3
-rw-r--r--lib/libutil/logwtmp.c3
-rw-r--r--lib/libutil/realhostname.c3
3 files changed, 3 insertions, 6 deletions
diff --git a/lib/libutil/login_times.c b/lib/libutil/login_times.c
index 10e88dd..0c64e93 100644
--- a/lib/libutil/login_times.c
+++ b/lib/libutil/login_times.c
@@ -72,8 +72,7 @@ parse_lt(const char * str)
char buf[64];
/* Make local copy and force lowercase to simplify parsing */
- p = strncpy(buf, str, sizeof buf);
- buf[sizeof buf - 1] = '\0';
+ p = strlcpy(buf, str, sizeof buf);
for (i = 0; buf[i]; i++)
buf[i] = (char)tolower(buf[i]);
diff --git a/lib/libutil/logwtmp.c b/lib/libutil/logwtmp.c
index a7b8411..6ae01a7 100644
--- a/lib/libutil/logwtmp.c
+++ b/lib/libutil/logwtmp.c
@@ -59,8 +59,7 @@ logwtmp(const char *line, const char *name, const char *host)
char fullhost[MAXHOSTNAMELEN];
int fd;
- strncpy(fullhost, host, sizeof(fullhost) - 1);
- fullhost[sizeof(fullhost) - 1] = '\0';
+ strlcpy(fullhost, host, sizeof(fullhost));
trimdomain(fullhost, UT_HOSTSIZE);
host = fullhost;
diff --git a/lib/libutil/realhostname.c b/lib/libutil/realhostname.c
index 6a1b82f..146695e 100644
--- a/lib/libutil/realhostname.c
+++ b/lib/libutil/realhostname.c
@@ -61,8 +61,7 @@ realhostname(char *host, size_t hsize, const struct in_addr *ip)
if (strlen(trimmed) <= hsize) {
char lookup[MAXHOSTNAMELEN];
- strncpy(lookup, hp->h_name, sizeof(lookup) - 1);
- lookup[sizeof(lookup) - 1] = '\0';
+ strlcpy(lookup, hp->h_name, sizeof(lookup));
hp = gethostbyname(lookup);
if (hp == NULL)
result = HOSTNAME_INVALIDNAME;
OpenPOWER on IntegriCloud