truncated - it was from OpenSSH on HP/UX and had all sorts of stuff in it
("last successful login" etc).
Bodged it by bumping up the space allocated in the fixed array for a password
prompt. Also added an indication that the prompt is being truncated, as
required by draft-ietf-secsh-auth-kbdinteract-06.
(NB that before this checkin, there was a more-or-less harmless buffer overread
where if we ever received a keyboard-interactive prompt with echo=1, we'd
probably spew goo on the terminal; fixed now.)
[originally from svn r4476]
int num_prompts, curr_prompt, echo;
char username[100];
int got_username;
int num_prompts, curr_prompt, echo;
char username[100];
int got_username;
char password[100];
void *publickey_blob;
int publickey_bloblen;
char password[100];
void *publickey_blob;
int publickey_bloblen;
ssh_pkt_getstring(ssh, &prompt, &prompt_len);
if (prompt_len > 0) {
ssh_pkt_getstring(ssh, &prompt, &prompt_len);
if (prompt_len > 0) {
- strncpy(s->pwprompt, prompt, sizeof(s->pwprompt));
- s->pwprompt[prompt_len < sizeof(s->pwprompt) ?
- prompt_len : sizeof(s->pwprompt)-1] = '\0';
+ static const char trunc[] = "<prompt truncated>: ";
+ static const int prlen = sizeof(s->pwprompt) -
+ lenof(trunc);
+ if (prompt_len > prlen) {
+ memcpy(s->pwprompt, prompt, prlen);
+ strcpy(s->pwprompt + prlen, trunc);
+ } else {
+ memcpy(s->pwprompt, prompt, prompt_len);
+ s->pwprompt[prompt_len] = '\0';
+ }
} else {
strcpy(s->pwprompt,
"<server failed to send prompt>: ");
} else {
strcpy(s->pwprompt,
"<server failed to send prompt>: ");