diff options
author | Xin LI <delphij@FreeBSD.org> | 2019-12-01 08:04:22 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2019-12-01 08:04:22 +0000 |
commit | 76b71718fe86d974e463624409c9f3ea040f7e2e (patch) | |
tree | c91712e6f5a8b0ba1ecbd02238480710a7354528 /libexec | |
parent | 84474332d3f3a0a1fcb051c250c6488437d16702 (diff) | |
download | src-test2-76b71718fe86d974e463624409c9f3ea040f7e2e.tar.gz src-test2-76b71718fe86d974e463624409c9f3ea040f7e2e.zip |
Notes
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/getty/main.c | 5 | ||||
-rw-r--r-- | libexec/getty/subr.c | 6 |
2 files changed, 4 insertions, 7 deletions
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 |