Simplify code with strlcpy/strlcat.
MFC after: 2 weeks
This commit is contained in:
parent
84474332d3
commit
76b71718fe
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user