From 8ed7622e3f439163a5b57edaaaedfc5a44cc0373 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sat, 9 May 2015 19:12:16 +0000 Subject: Replace malloc(3) + strcpy(3) + strcat(3) by asprintf(3) --- pw/pw_user.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'pw/pw_user.c') 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) { -- cgit v1.2.3