diff options
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r-- | ssh-keyscan.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c index ab7f33d04..1b4f3a1bb 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "includes.h" | 10 | #include "includes.h" |
11 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.20 2001/03/05 15:37:27 deraadt Exp $"); | 11 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.21 2001/03/06 01:06:03 millert Exp $"); |
12 | 12 | ||
13 | #if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H) | 13 | #if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H) |
14 | #include <sys/queue.h> | 14 | #include <sys/queue.h> |
@@ -411,23 +411,27 @@ conrecycle(int s) | |||
411 | void | 411 | void |
412 | congreet(int s) | 412 | congreet(int s) |
413 | { | 413 | { |
414 | char buf[80]; | 414 | char buf[80], *cp; |
415 | size_t bufsiz; | ||
415 | int n; | 416 | int n; |
416 | con *c = &fdcon[s]; | 417 | con *c = &fdcon[s]; |
417 | 418 | ||
418 | n = read(s, buf, sizeof(buf)); | 419 | bufsiz = sizeof(buf); |
420 | cp = buf; | ||
421 | while (bufsiz-- && (n = read(s, cp, 1)) == 1 && *cp != '\n' && *cp != '\r') | ||
422 | cp++; | ||
419 | if (n < 0) { | 423 | if (n < 0) { |
420 | if (errno != ECONNREFUSED) | 424 | if (errno != ECONNREFUSED) |
421 | error("read (%s): %s", c->c_name, strerror(errno)); | 425 | error("read (%s): %s", c->c_name, strerror(errno)); |
422 | conrecycle(s); | 426 | conrecycle(s); |
423 | return; | 427 | return; |
424 | } | 428 | } |
425 | if (buf[n - 1] != '\n') { | 429 | if (*cp != '\n' && *cp != '\r') { |
426 | error("%s: bad greeting", c->c_name); | 430 | error("%s: bad greeting", c->c_name); |
427 | confree(s); | 431 | confree(s); |
428 | return; | 432 | return; |
429 | } | 433 | } |
430 | buf[n - 1] = '\0'; | 434 | *cp = '\0'; |
431 | fprintf(stderr, "# %s %s\n", c->c_name, buf); | 435 | fprintf(stderr, "# %s %s\n", c->c_name, buf); |
432 | n = snprintf(buf, sizeof buf, "SSH-1.5-OpenSSH-keyscan\r\n"); | 436 | n = snprintf(buf, sizeof buf, "SSH-1.5-OpenSSH-keyscan\r\n"); |
433 | if (atomicio(write, s, buf, n) != n) { | 437 | if (atomicio(write, s, buf, n) != n) { |