static char* new_password(const struct passwd *pw, uid_t myuid, const char *algo)
{
char salt[MAX_PW_SALT_LEN];
- char *orig = (char*)"";
+ char *orig = NULL;
char *newp = NULL;
char *cp = NULL;
char *ret = NULL; /* failure so far */
if (myuid != 0 && pw->pw_passwd[0]) {
char *encrypted;
- orig = bb_ask_noecho_stdin("Old password: "); /* returns ptr to static */
+ orig = bb_ask_noecho_stdin("Old password: "); /* returns malloced str */
if (!orig)
goto err_ret;
encrypted = pw_encrypt(orig, pw->pw_passwd, 1); /* returns malloced str */
if (ENABLE_FEATURE_CLEAN_UP)
free(encrypted);
}
- newp = bb_ask_noecho_stdin("New password: "); /* returns ptr to static */
+ newp = bb_ask_noecho_stdin("New password: "); /* returns malloced str */
if (!newp)
goto err_ret;
if (ENABLE_FEATURE_PASSWD_WEAK_CHECK
- && obscure(orig, newp, pw)
+ && obscure(orig, newp, pw) /* NB: passing NULL orig is ok */
&& myuid != 0
) {
goto err_ret; /* non-root is not allowed to have weak passwd */