summaryrefslogtreecommitdiff
path: root/sshconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshconnect.c')
-rw-r--r--sshconnect.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sshconnect.c b/sshconnect.c
index 2b9ce9ddd..a2d759819 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.325 2020/01/11 16:23:10 naddy Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.326 2020/01/22 07:38:30 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -580,22 +580,23 @@ confirm(const char *prompt, const char *fingerprint)
580{ 580{
581 const char *msg, *again = "Please type 'yes' or 'no': "; 581 const char *msg, *again = "Please type 'yes' or 'no': ";
582 const char *again_fp = "Please type 'yes', 'no' or the fingerprint: "; 582 const char *again_fp = "Please type 'yes', 'no' or the fingerprint: ";
583 char *p; 583 char *p, *cp;
584 int ret = -1; 584 int ret = -1;
585 585
586 if (options.batch_mode) 586 if (options.batch_mode)
587 return 0; 587 return 0;
588 for (msg = prompt;;msg = fingerprint ? again_fp : again) { 588 for (msg = prompt;;msg = fingerprint ? again_fp : again) {
589 p = read_passphrase(msg, RP_ECHO); 589 cp = p = read_passphrase(msg, RP_ECHO);
590 if (p == NULL) 590 if (p == NULL)
591 return 0; 591 return 0;
592 p[strcspn(p, "\n")] = '\0'; 592 p += strspn(p, " \t"); /* skip leading whitespace */
593 p[strcspn(p, " \t\n")] = '\0'; /* remove trailing whitespace */
593 if (p[0] == '\0' || strcasecmp(p, "no") == 0) 594 if (p[0] == '\0' || strcasecmp(p, "no") == 0)
594 ret = 0; 595 ret = 0;
595 else if (strcasecmp(p, "yes") == 0 || (fingerprint != NULL && 596 else if (strcasecmp(p, "yes") == 0 || (fingerprint != NULL &&
596 strcasecmp(p, fingerprint) == 0)) 597 strcasecmp(p, fingerprint) == 0))
597 ret = 1; 598 ret = 1;
598 free(p); 599 free(cp);
599 if (ret != -1) 600 if (ret != -1)
600 return ret; 601 return ret;
601 } 602 }