Replace strncpy -> strlcpy

Obtained from:	OpenBSD
MFC after:	1 week
This commit is contained in:
Kris Kennaway 2001-07-24 11:36:56 +00:00
parent 6979f76ff6
commit fd96447ad0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=80275

View File

@ -132,8 +132,7 @@ add_tty(name)
tp->ret = 0; tp->ret = 0;
name++; name++;
} }
(void)strncpy(tp->name, name, sizeof (tp->name) - 1); strlcpy(tp->name, name, sizeof (tp->name));
tp->name[sizeof (tp->name) - 1] = '\0';
if ((rcp = strchr(tp->name, '*')) != NULL) { /* wild card */ if ((rcp = strchr(tp->name, '*')) != NULL) { /* wild card */
*rcp = '\0'; *rcp = '\0';
tp->len = strlen(tp->name); /* match len bytes only */ tp->len = strlen(tp->name); /* match len bytes only */
@ -213,8 +212,7 @@ update_user(head, name, secs)
if ((up = NEW(struct user_list)) == NULL) if ((up = NEW(struct user_list)) == NULL)
errx(1, "malloc failed"); errx(1, "malloc failed");
up->next = head; up->next = head;
(void)strncpy(up->name, name, sizeof (up->name) - 1); strlcpy(up->name, name, sizeof (up->name));
up->name[sizeof (up->name) - 1] = '\0'; /* paranoid! */
up->secs = secs; up->secs = secs;
Total += secs; Total += secs;
return up; return up;
@ -429,8 +427,7 @@ log_in(head, up)
/* /*
* this allows us to pick the right logout * this allows us to pick the right logout
*/ */
(void)strncpy(up->ut_line, Console, sizeof (up->ut_line) - 1); strlcpy(up->ut_line, Console, sizeof (up->ut_line));
up->ut_line[sizeof (up->ut_line) - 1] = '\0'; /* paranoid! */
} }
#endif #endif
/* /*