Use snprintf(3) instead of sprintf(3)
Remove useless "else"
This commit is contained in:
parent
8592cfc58e
commit
5d8ece9a4b
@ -1018,17 +1018,16 @@ static char *
|
|||||||
pw_homepolicy(struct userconf * cnf, struct cargs * args, char const * user)
|
pw_homepolicy(struct userconf * cnf, struct cargs * args, char const * user)
|
||||||
{
|
{
|
||||||
struct carg *arg = getarg(args, 'd');
|
struct carg *arg = getarg(args, 'd');
|
||||||
|
static char home[128];
|
||||||
|
|
||||||
if (arg)
|
if (arg)
|
||||||
return arg->val;
|
return (arg->val);
|
||||||
else {
|
|
||||||
static char home[128];
|
|
||||||
|
|
||||||
if (cnf->home == NULL || *cnf->home == '\0')
|
if (cnf->home == NULL || *cnf->home == '\0')
|
||||||
errx(EX_CONFIG, "no base home directory set");
|
errx(EX_CONFIG, "no base home directory set");
|
||||||
sprintf(home, "%s/%s", cnf->home, user);
|
snprintf(home, sizeof(home), "%s/%s", cnf->home, user);
|
||||||
return home;
|
|
||||||
}
|
return (home);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user