diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2001-12-21 08:53:46 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2001-12-21 08:53:46 +0000 |
commit | da616515814da9ec258eda561227d029181560d6 (patch) | |
tree | e129903aa3486dd62766646d8f3aa796f959f574 /usr.bin | |
parent | 3e648721f34661f70957c27f50ba7f946705ccea (diff) |
Avoid interruptable passphrase read; ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/readpass.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/ssh/readpass.c b/usr.bin/ssh/readpass.c index 0fa1ce33de9..090235af1d4 100644 --- a/usr.bin/ssh/readpass.c +++ b/usr.bin/ssh/readpass.c @@ -32,7 +32,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: readpass.c,v 1.23 2001/11/08 10:51:08 markus Exp $"); +RCSID("$OpenBSD: readpass.c,v 1.24 2001/12/21 08:53:45 djm Exp $"); #include <readpassphrase.h> @@ -48,7 +48,7 @@ ssh_askpass(char *askpass, const char *msg) pid_t pid; size_t len; char *pass; - int p[2], status; + int p[2], status, ret; char buf[1024]; if (fflush(stdout) != 0) @@ -73,14 +73,23 @@ ssh_askpass(char *askpass, const char *msg) fatal("ssh_askpass: exec(%s): %s", askpass, strerror(errno)); } close(p[1]); - len = read(p[0], buf, sizeof buf -1); + + len = ret = 0; + do { + ret = read(p[0], buf + len, sizeof(buf) - 1 - len); + if (ret == -1 && errno == EINTR) + continue; + if (ret <= 0) + break; + len += ret; + } while (sizeof(buf) - 1 - len > 0); + buf[len] = '\0'; + close(p[0]); while (waitpid(pid, &status, 0) < 0) if (errno != EINTR) break; - if (len <= 1) - return xstrdup(""); - buf[len] = '\0'; + buf[strcspn(buf, "\r\n")] = '\0'; pass = xstrdup(buf); memset(buf, 0, sizeof(buf)); |