Use strlcpy() when we mean it.

This commit is contained in:
Xin LI 2008-10-17 21:14:50 +00:00
parent 76a7756334
commit 1c10962832
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=183988
2 changed files with 3 additions and 6 deletions

View File

@ -1145,8 +1145,7 @@ inetname(struct in_addr *inp)
if (inp->s_addr == INADDR_ANY)
strcpy(line, "*");
else if (cp) {
strncpy(line, cp, sizeof(line) - 1);
line[sizeof(line) - 1] = '\0';
strlcpy(line, cp, sizeof(line));
} else {
inp->s_addr = ntohl(inp->s_addr);
#define C(x) ((u_int)((x) & 0xff))

View File

@ -836,8 +836,7 @@ routename(in_addr_t in)
}
}
if (cp) {
strncpy(line, cp, sizeof(line) - 1);
line[sizeof(line) - 1] = '\0';
strlcpy(line, cp, sizeof(line));
} else {
#define C(x) ((x) & 0xff)
in = ntohl(in);
@ -902,8 +901,7 @@ netname(in_addr_t in, u_long mask)
}
}
if (cp != NULL) {
strncpy(line, cp, sizeof(line) - 1);
line[sizeof(line) - 1] = '\0';
strlcpy(line, cp, sizeof(line));
} else {
inet_ntop(AF_INET, &in, line, sizeof(line) - 1);
}