diff --git a/src/passwd.c b/src/passwd.c index 4549d95d..ee25373b 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -195,6 +195,7 @@ static int new_password (const struct passwd *pw) char orig[PASS_MAX + 1]; /* Original password */ char pass[PASS_MAX + 1]; /* New password */ int i; /* Counter for retries */ + int ret; bool warned; int pass_max_len = -1; const char *method; @@ -300,8 +301,14 @@ static int new_password (const struct passwd *pw) if (warned && (strcmp (pass, cp) != 0)) { warned = false; } - STRFCPY (pass, cp); + ret = STRTCPY (pass, cp); erase_pass (cp); + if (ret == -1) { + (void) fputs (_("Password is too long.\n"), stderr); + memzero (orig, sizeof orig); + memzero (pass, sizeof pass); + return -1; + } if (!amroot && (!obscure (orig, pass, pw) || reuse (pass, pw))) { (void) puts (_("Try again."));