diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2006-03-22 19:46:12 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2006-03-22 19:46:12 +0000 |
commit | 021d409f5beb1827f72d24f171e3c3ed233ed62a (patch) | |
tree | 42b3633dec62ddc0b702c6e83df5d64683b1c6c3 /crypto/openssh/ssh-keyscan.c | |
parent | 043840df5be0cf8490b48a08fe6d9c316f473f58 (diff) | |
download | src-test2-021d409f5beb1827f72d24f171e3c3ed233ed62a.tar.gz src-test2-021d409f5beb1827f72d24f171e3c3ed233ed62a.zip |
Notes
Diffstat (limited to 'crypto/openssh/ssh-keyscan.c')
-rw-r--r-- | crypto/openssh/ssh-keyscan.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/crypto/openssh/ssh-keyscan.c b/crypto/openssh/ssh-keyscan.c index 46f063687b16..6915102ddf3b 100644 --- a/crypto/openssh/ssh-keyscan.c +++ b/crypto/openssh/ssh-keyscan.c @@ -7,7 +7,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-keyscan.c,v 1.55 2005/06/17 02:44:33 djm Exp $"); +RCSID("$OpenBSD: ssh-keyscan.c,v 1.57 2005/10/30 04:01:03 djm Exp $"); #include "openbsd-compat/sys-queue.h" @@ -499,12 +499,18 @@ congreet(int s) size_t bufsiz; con *c = &fdcon[s]; - bufsiz = sizeof(buf); - cp = buf; - while (bufsiz-- && (n = atomicio(read, s, cp, 1)) == 1 && *cp != '\n') { - if (*cp == '\r') - *cp = '\n'; - cp++; + for (;;) { + memset(buf, '\0', sizeof(buf)); + bufsiz = sizeof(buf); + cp = buf; + while (bufsiz-- && + (n = atomicio(read, s, cp, 1)) == 1 && *cp != '\n') { + if (*cp == '\r') + *cp = '\n'; + cp++; + } + if (n != 1 || strncmp(buf, "SSH-", 4) == 0) + break; } if (n == 0) { switch (errno) { @@ -712,6 +718,9 @@ main(int argc, char **argv) seed_rng(); TAILQ_INIT(&tq); + /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ + sanitise_stdfd(); + if (argc <= 1) usage(); |