From: Martin Kletzander Date: Fri, 3 Mar 2023 10:57:23 +0000 (+0100) Subject: usermod: Small optimization using memmove for password unlock X-Git-Tag: 4.14.0-rc1~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8665fe1957b0d565701ff1b834eae89e5c4d2c9a;p=thirdparty%2Fshadow.git usermod: Small optimization using memmove for password unlock Signed-off-by: Martin Kletzander --- diff --git a/src/usermod.c b/src/usermod.c index 87c93d93c..77d4ef491 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -430,8 +430,6 @@ static char *new_pw_passwd (char *pw_pass) strcat (buf, pw_pass); pw_pass = buf; } else if (Uflg && pw_pass[0] == '!') { - char *s; - if (pw_pass[1] == '\0') { fprintf (stderr, _("%s: unlocking the user's password would result in a passwordless account.\n" @@ -445,11 +443,7 @@ static char *new_pw_passwd (char *pw_pass) "updating password", user_newname, user_newid, 0); #endif SYSLOG ((LOG_INFO, "unlock user '%s' password", user_newname)); - s = pw_pass; - while ('\0' != *s) { - *s = *(s + 1); - s++; - } + memmove(pw_pass, pw_pass + 1, strlen(pw_pass)); } else if (pflg) { #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog,