summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--readpass.c21
2 files changed, 19 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index a7e62cdb4..db387db2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,9 @@
13 - djm@cvs.openbsd.org 2001/12/21 08:52:22 13 - djm@cvs.openbsd.org 2001/12/21 08:52:22
14 [ssh-keygen.1 ssh-keygen.c] 14 [ssh-keygen.1 ssh-keygen.c]
15 Remove default (rsa1) key type; ok markus@ 15 Remove default (rsa1) key type; ok markus@
16 - djm@cvs.openbsd.org 2001/12/21 08:53:45
17 [readpass.c]
18 Avoid interruptable passphrase read; ok markus@
16 19
1720020121 2020020121
18 - (djm) Rework ssh-rand-helper: 21 - (djm) Rework ssh-rand-helper:
@@ -7160,4 +7163,4 @@
7160 - Wrote replacements for strlcpy and mkdtemp 7163 - Wrote replacements for strlcpy and mkdtemp
7161 - Released 1.0pre1 7164 - Released 1.0pre1
7162 7165
7163$Id: ChangeLog,v 1.1725 2002/01/22 12:05:08 djm Exp $ 7166$Id: ChangeLog,v 1.1726 2002/01/22 12:05:31 djm Exp $
diff --git a/readpass.c b/readpass.c
index a0429818e..7e13828b7 100644
--- a/readpass.c
+++ b/readpass.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#include "includes.h" 34#include "includes.h"
35RCSID("$OpenBSD: readpass.c,v 1.23 2001/11/08 10:51:08 markus Exp $"); 35RCSID("$OpenBSD: readpass.c,v 1.24 2001/12/21 08:53:45 djm Exp $");
36 36
37#include "xmalloc.h" 37#include "xmalloc.h"
38#include "readpass.h" 38#include "readpass.h"
@@ -46,7 +46,7 @@ ssh_askpass(char *askpass, const char *msg)
46 pid_t pid; 46 pid_t pid;
47 size_t len; 47 size_t len;
48 char *pass; 48 char *pass;
49 int p[2], status; 49 int p[2], status, ret;
50 char buf[1024]; 50 char buf[1024];
51 51
52 if (fflush(stdout) != 0) 52 if (fflush(stdout) != 0)
@@ -71,14 +71,23 @@ ssh_askpass(char *askpass, const char *msg)
71 fatal("ssh_askpass: exec(%s): %s", askpass, strerror(errno)); 71 fatal("ssh_askpass: exec(%s): %s", askpass, strerror(errno));
72 } 72 }
73 close(p[1]); 73 close(p[1]);
74 len = read(p[0], buf, sizeof buf -1); 74
75 len = ret = 0;
76 do {
77 ret = read(p[0], buf + len, sizeof(buf) - 1 - len);
78 if (ret == -1 && errno == EINTR)
79 continue;
80 if (ret <= 0)
81 break;
82 len += ret;
83 } while (sizeof(buf) - 1 - len > 0);
84 buf[len] = '\0';
85
75 close(p[0]); 86 close(p[0]);
76 while (waitpid(pid, &status, 0) < 0) 87 while (waitpid(pid, &status, 0) < 0)
77 if (errno != EINTR) 88 if (errno != EINTR)
78 break; 89 break;
79 if (len <= 1) 90
80 return xstrdup("");
81 buf[len] = '\0';
82 buf[strcspn(buf, "\r\n")] = '\0'; 91 buf[strcspn(buf, "\r\n")] = '\0';
83 pass = xstrdup(buf); 92 pass = xstrdup(buf);
84 memset(buf, 0, sizeof(buf)); 93 memset(buf, 0, sizeof(buf));