bsdauth_verify: do not write to prompt, it is now const

This commit is contained in:
Todd C. Miller
2022-11-01 09:33:19 -06:00
parent d242261dd4
commit 7ec1ee0e5c

View File

@@ -133,7 +133,7 @@ bsdauth_verify(struct passwd *pw, const char *prompt, sudo_auth *auth, struct su
pass = auth_getpass(prompt, SUDO_CONV_PROMPT_ECHO_OFF, callback);
} else {
pass = auth_getpass(s, SUDO_CONV_PROMPT_ECHO_OFF, callback);
if (pass && *pass == '\0') {
if (pass != NULL && *pass == '\0') {
if ((prompt = strrchr(s, '\n')))
prompt++;
else
@@ -141,12 +141,12 @@ bsdauth_verify(struct passwd *pw, const char *prompt, sudo_auth *auth, struct su
/*
* Append '[echo on]' to the last line of the challenge and
* reprompt with echo turned on.
* re-prompt with echo turned on.
*/
len = strlen(prompt) - 1;
while (isspace(prompt[len]) || prompt[len] == ':')
prompt[len--] = '\0';
if (asprintf(&s, "%s [echo on]: ", prompt) == -1) {
len = strlen(prompt);
while (len > 0 && (isspace((unsigned char)prompt[len - 1]) || prompt[len - 1] == ':'))
len--;
if (asprintf(&s, "%.*s [echo on]: ", (int)len, prompt) == -1) {
log_warningx(0, N_("unable to allocate memory"));
debug_return_int(AUTH_FATAL);
}