summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pw/pw_user.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c
index 0f7dd26..dc9a2d8 100644
--- a/pw/pw_user.c
+++ b/pw/pw_user.c
@@ -363,11 +363,9 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (mode == M_LOCK) {
if (strncmp(pwd->pw_passwd, locked_str, sizeof(locked_str)-1) == 0)
errx(EX_DATAERR, "user '%s' is already locked", pwd->pw_name);
- passtmp = malloc(strlen(pwd->pw_passwd) + sizeof(locked_str));
+ asprintf(&passtmp, "%s%s", locked_str, pwd->pw_passwd);
if (passtmp == NULL) /* disaster */
errx(EX_UNAVAILABLE, "out of memory");
- strcpy(passtmp, locked_str);
- strcat(passtmp, pwd->pw_passwd);
pwd->pw_passwd = passtmp;
edited = 1;
} else if (mode == M_UNLOCK) {