bsdauth_verify: do not write to prompt, it is now const
This commit is contained in:
@@ -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);
|
pass = auth_getpass(prompt, SUDO_CONV_PROMPT_ECHO_OFF, callback);
|
||||||
} else {
|
} else {
|
||||||
pass = auth_getpass(s, SUDO_CONV_PROMPT_ECHO_OFF, callback);
|
pass = auth_getpass(s, SUDO_CONV_PROMPT_ECHO_OFF, callback);
|
||||||
if (pass && *pass == '\0') {
|
if (pass != NULL && *pass == '\0') {
|
||||||
if ((prompt = strrchr(s, '\n')))
|
if ((prompt = strrchr(s, '\n')))
|
||||||
prompt++;
|
prompt++;
|
||||||
else
|
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
|
* 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;
|
len = strlen(prompt);
|
||||||
while (isspace(prompt[len]) || prompt[len] == ':')
|
while (len > 0 && (isspace((unsigned char)prompt[len - 1]) || prompt[len - 1] == ':'))
|
||||||
prompt[len--] = '\0';
|
len--;
|
||||||
if (asprintf(&s, "%s [echo on]: ", prompt) == -1) {
|
if (asprintf(&s, "%.*s [echo on]: ", (int)len, prompt) == -1) {
|
||||||
log_warningx(0, N_("unable to allocate memory"));
|
log_warningx(0, N_("unable to allocate memory"));
|
||||||
debug_return_int(AUTH_FATAL);
|
debug_return_int(AUTH_FATAL);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user