]> andersk Git - openssh.git/commitdiff
- djm@cvs.openbsd.org 2001/12/21 08:53:45
authordjm <djm>
Tue, 22 Jan 2002 12:05:31 +0000 (12:05 +0000)
committerdjm <djm>
Tue, 22 Jan 2002 12:05:31 +0000 (12:05 +0000)
     [readpass.c]
     Avoid interruptable passphrase read; ok markus@

ChangeLog
readpass.c

index 88114f091c51b7d32d9ccd7f76ce22d11c4a1581..74551d4355ee0579ea2fbaed14c3b4bf33455642 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,9 @@
    - djm@cvs.openbsd.org 2001/12/21 08:52:22
      [ssh-keygen.1 ssh-keygen.c]
      Remove default (rsa1) key type; ok markus@
+   - djm@cvs.openbsd.org 2001/12/21 08:53:45
+     [readpass.c]
+     Avoid interruptable passphrase read; ok markus@
 
 20020121
  - (djm) Rework ssh-rand-helper:
index a0429818e7c5ce8c9f84506daa520641a7615d0b..7e13828b7dcb854d6a0d375bdf98b4371a72228f 100644 (file)
@@ -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 "xmalloc.h"
 #include "readpass.h"
@@ -46,7 +46,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)
@@ -71,14 +71,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));
This page took 0.224698 seconds and 5 git commands to generate.