From 020fd2ca7fd6eb436c750af2f59d5d60c9b9d221 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sat, 9 May 2015 22:43:44 +0000 Subject: Use snprintf(3) instead of sprintf(3) Remove useless "else" --- pw/pw_user.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'pw/pw_user.c') diff --git a/pw/pw_user.c b/pw/pw_user.c index bdb3cd6..d7aed71 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -1018,17 +1018,16 @@ static char * pw_homepolicy(struct userconf * cnf, struct cargs * args, char const * user) { struct carg *arg = getarg(args, 'd'); + static char home[128]; if (arg) - return arg->val; - else { - static char home[128]; + return (arg->val); - if (cnf->home == NULL || *cnf->home == '\0') - errx(EX_CONFIG, "no base home directory set"); - sprintf(home, "%s/%s", cnf->home, user); - return home; - } + if (cnf->home == NULL || *cnf->home == '\0') + errx(EX_CONFIG, "no base home directory set"); + snprintf(home, sizeof(home), "%s/%s", cnf->home, user); + + return (home); } static char * -- cgit v1.2.3-56-ge451