diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-11-08 10:51:09 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-11-08 10:51:09 +0000 |
commit | 8fae0e3a92a872ef180e93cc670e0579b39645fc (patch) | |
tree | ca0402076736cebdc55e7490f02a0440da168b78 /usr.bin | |
parent | b9870b0b31e0c7957c8f97599f0e1fde3b2744f5 (diff) |
don't strdup too much data; from gotoh@taiyo.co.jp; ok millert.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/readpass.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.bin/ssh/readpass.c b/usr.bin/ssh/readpass.c index 4d967608557..0fa1ce33de9 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.22 2001/07/14 15:10:16 stevesk Exp $"); +RCSID("$OpenBSD: readpass.c,v 1.23 2001/11/08 10:51:08 markus Exp $"); #include <readpassphrase.h> @@ -47,7 +47,7 @@ ssh_askpass(char *askpass, const char *msg) { pid_t pid; size_t len; - char *nl, *pass; + char *pass; int p[2], status; char buf[1024]; @@ -73,16 +73,15 @@ 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); + len = read(p[0], buf, sizeof buf -1); close(p[0]); while (waitpid(pid, &status, 0) < 0) if (errno != EINTR) break; if (len <= 1) return xstrdup(""); - nl = strchr(buf, '\n'); - if (nl) - *nl = '\0'; + buf[len] = '\0'; + buf[strcspn(buf, "\r\n")] = '\0'; pass = xstrdup(buf); memset(buf, 0, sizeof(buf)); return pass; |