diff --git a/libexec/getty/main.c b/libexec/getty/main.c index 78b352d11884..743a0508c561 100644 --- a/libexec/getty/main.c +++ b/libexec/getty/main.c @@ -97,7 +97,6 @@ static int crmod, digit, lower, upper; char hostname[MAXHOSTNAMELEN]; static char name[MAXLOGNAME*3]; -static char dev[] = _PATH_DEV; static char ttyn[32]; #define OBUFSIZ 128 @@ -218,8 +217,8 @@ main(int argc, char *argv[]) if (argc <= 2 || strcmp(argv[2], "-") == 0) strcpy(ttyn, ttyname(STDIN_FILENO)); else { - strcpy(ttyn, dev); - strncat(ttyn, argv[2], sizeof(ttyn)-sizeof(dev)); + strcpy(ttyn, _PATH_DEV); + strlcat(ttyn, argv[2], sizeof(ttyn)); if (strcmp(argv[0], "+") != 0) { chown(ttyn, 0, 0); chmod(ttyn, 0600); diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c index 7f8c996969d7..9958d193aa60 100644 --- a/libexec/getty/subr.c +++ b/libexec/getty/subr.c @@ -89,10 +89,8 @@ gettable(const char *name, char *buf) l = 2; else l = strlen(sp->value) + 1; - if ((p = malloc(l)) != NULL) { - strncpy(p, sp->value, l); - p[l-1] = '\0'; - } + if ((p = malloc(l)) != NULL) + strlcpy(p, sp->value, l); /* * replace, even if NULL, else we'll * have problems with free()ing static mem