diff options
author | Colin Watson <cjwatson@debian.org> | 2005-09-14 12:45:47 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2005-09-14 12:45:47 +0000 |
commit | 9b71add4cecf753c45f5fbd6ff0913bc95b3e95d (patch) | |
tree | d4ea8fdb30c7949c6433f5277c39548ea579d4dc /ssh-keyscan.c | |
parent | ed07bcbea56007ab5b218ddf3aa6a7d4e21966e0 (diff) | |
parent | 16704d57999d987fb8d9ba53379841a79f016d67 (diff) |
Merge 4.2p1 to the trunk.
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r-- | ssh-keyscan.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c index 7d10c6c3e..64eecfb9a 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c | |||
@@ -7,7 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "includes.h" | 9 | #include "includes.h" |
10 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.52 2005/03/01 15:47:14 jmc Exp $"); | 10 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.55 2005/06/17 02:44:33 djm Exp $"); |
11 | 11 | ||
12 | #include "openbsd-compat/sys-queue.h" | 12 | #include "openbsd-compat/sys-queue.h" |
13 | 13 | ||
@@ -166,7 +166,7 @@ Linebuf_lineno(Linebuf * lb) | |||
166 | static char * | 166 | static char * |
167 | Linebuf_getline(Linebuf * lb) | 167 | Linebuf_getline(Linebuf * lb) |
168 | { | 168 | { |
169 | int n = 0; | 169 | size_t n = 0; |
170 | void *p; | 170 | void *p; |
171 | 171 | ||
172 | lb->lineno++; | 172 | lb->lineno++; |
@@ -493,7 +493,7 @@ conrecycle(int s) | |||
493 | static void | 493 | static void |
494 | congreet(int s) | 494 | congreet(int s) |
495 | { | 495 | { |
496 | int remote_major = 0, remote_minor = 0, n = 0; | 496 | int n = 0, remote_major = 0, remote_minor = 0; |
497 | char buf[256], *cp; | 497 | char buf[256], *cp; |
498 | char remote_version[sizeof buf]; | 498 | char remote_version[sizeof buf]; |
499 | size_t bufsiz; | 499 | size_t bufsiz; |
@@ -506,14 +506,17 @@ congreet(int s) | |||
506 | *cp = '\n'; | 506 | *cp = '\n'; |
507 | cp++; | 507 | cp++; |
508 | } | 508 | } |
509 | if (n < 0) { | ||
510 | if (errno != ECONNREFUSED) | ||
511 | error("read (%s): %s", c->c_name, strerror(errno)); | ||
512 | conrecycle(s); | ||
513 | return; | ||
514 | } | ||
515 | if (n == 0) { | 509 | if (n == 0) { |
516 | error("%s: Connection closed by remote host", c->c_name); | 510 | switch (errno) { |
511 | case EPIPE: | ||
512 | error("%s: Connection closed by remote host", c->c_name); | ||
513 | break; | ||
514 | case ECONNREFUSED: | ||
515 | break; | ||
516 | default: | ||
517 | error("read (%s): %s", c->c_name, strerror(errno)); | ||
518 | break; | ||
519 | } | ||
517 | conrecycle(s); | 520 | conrecycle(s); |
518 | return; | 521 | return; |
519 | } | 522 | } |
@@ -543,7 +546,12 @@ congreet(int s) | |||
543 | n = snprintf(buf, sizeof buf, "SSH-%d.%d-OpenSSH-keyscan\r\n", | 546 | n = snprintf(buf, sizeof buf, "SSH-%d.%d-OpenSSH-keyscan\r\n", |
544 | c->c_keytype == KT_RSA1? PROTOCOL_MAJOR_1 : PROTOCOL_MAJOR_2, | 547 | c->c_keytype == KT_RSA1? PROTOCOL_MAJOR_1 : PROTOCOL_MAJOR_2, |
545 | c->c_keytype == KT_RSA1? PROTOCOL_MINOR_1 : PROTOCOL_MINOR_2); | 548 | c->c_keytype == KT_RSA1? PROTOCOL_MINOR_1 : PROTOCOL_MINOR_2); |
546 | if (atomicio(vwrite, s, buf, n) != n) { | 549 | if (n < 0 || (size_t)n >= sizeof(buf)) { |
550 | error("snprintf: buffer too small"); | ||
551 | confree(s); | ||
552 | return; | ||
553 | } | ||
554 | if (atomicio(vwrite, s, buf, n) != (size_t)n) { | ||
547 | error("write (%s): %s", c->c_name, strerror(errno)); | 555 | error("write (%s): %s", c->c_name, strerror(errno)); |
548 | confree(s); | 556 | confree(s); |
549 | return; | 557 | return; |
@@ -561,14 +569,14 @@ static void | |||
561 | conread(int s) | 569 | conread(int s) |
562 | { | 570 | { |
563 | con *c = &fdcon[s]; | 571 | con *c = &fdcon[s]; |
564 | int n; | 572 | size_t n; |
565 | 573 | ||
566 | if (c->c_status == CS_CON) { | 574 | if (c->c_status == CS_CON) { |
567 | congreet(s); | 575 | congreet(s); |
568 | return; | 576 | return; |
569 | } | 577 | } |
570 | n = atomicio(read, s, c->c_data + c->c_off, c->c_len - c->c_off); | 578 | n = atomicio(read, s, c->c_data + c->c_off, c->c_len - c->c_off); |
571 | if (n < 0) { | 579 | if (n == 0) { |
572 | error("read (%s): %s", c->c_name, strerror(errno)); | 580 | error("read (%s): %s", c->c_name, strerror(errno)); |
573 | confree(s); | 581 | confree(s); |
574 | return; | 582 | return; |