summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/ssh-keyscan.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2005-09-03 06:59:33 +0000
committerdes <des@FreeBSD.org>2005-09-03 06:59:33 +0000
commit755a16fa864cacbbd9fbefc822011b6741351d8d (patch)
treeb8088b859d6543143de670740f5c6f7bf4e0b23d /crypto/openssh/ssh-keyscan.c
parentc4dfc1ed3bdacd05d73791b2c8f8b580511a939f (diff)
downloadFreeBSD-src-755a16fa864cacbbd9fbefc822011b6741351d8d.zip
FreeBSD-src-755a16fa864cacbbd9fbefc822011b6741351d8d.tar.gz
Vendor import of OpenSSH 4.2p1.
Diffstat (limited to 'crypto/openssh/ssh-keyscan.c')
-rw-r--r--crypto/openssh/ssh-keyscan.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/crypto/openssh/ssh-keyscan.c b/crypto/openssh/ssh-keyscan.c
index bc2c3b7..46f0636 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.52 2005/03/01 15:47:14 jmc Exp $");
+RCSID("$OpenBSD: ssh-keyscan.c,v 1.55 2005/06/17 02:44:33 djm Exp $");
#include "openbsd-compat/sys-queue.h"
@@ -166,7 +166,7 @@ Linebuf_lineno(Linebuf * lb)
static char *
Linebuf_getline(Linebuf * lb)
{
- int n = 0;
+ size_t n = 0;
void *p;
lb->lineno++;
@@ -493,7 +493,7 @@ conrecycle(int s)
static void
congreet(int s)
{
- int remote_major = 0, remote_minor = 0, n = 0;
+ int n = 0, remote_major = 0, remote_minor = 0;
char buf[256], *cp;
char remote_version[sizeof buf];
size_t bufsiz;
@@ -506,14 +506,17 @@ congreet(int s)
*cp = '\n';
cp++;
}
- if (n < 0) {
- if (errno != ECONNREFUSED)
- error("read (%s): %s", c->c_name, strerror(errno));
- conrecycle(s);
- return;
- }
if (n == 0) {
- error("%s: Connection closed by remote host", c->c_name);
+ switch (errno) {
+ case EPIPE:
+ error("%s: Connection closed by remote host", c->c_name);
+ break;
+ case ECONNREFUSED:
+ break;
+ default:
+ error("read (%s): %s", c->c_name, strerror(errno));
+ break;
+ }
conrecycle(s);
return;
}
@@ -543,7 +546,12 @@ congreet(int s)
n = snprintf(buf, sizeof buf, "SSH-%d.%d-OpenSSH-keyscan\r\n",
c->c_keytype == KT_RSA1? PROTOCOL_MAJOR_1 : PROTOCOL_MAJOR_2,
c->c_keytype == KT_RSA1? PROTOCOL_MINOR_1 : PROTOCOL_MINOR_2);
- if (atomicio(vwrite, s, buf, n) != n) {
+ if (n < 0 || (size_t)n >= sizeof(buf)) {
+ error("snprintf: buffer too small");
+ confree(s);
+ return;
+ }
+ if (atomicio(vwrite, s, buf, n) != (size_t)n) {
error("write (%s): %s", c->c_name, strerror(errno));
confree(s);
return;
@@ -561,14 +569,14 @@ static void
conread(int s)
{
con *c = &fdcon[s];
- int n;
+ size_t n;
if (c->c_status == CS_CON) {
congreet(s);
return;
}
n = atomicio(read, s, c->c_data + c->c_off, c->c_len - c->c_off);
- if (n < 0) {
+ if (n == 0) {
error("read (%s): %s", c->c_name, strerror(errno));
confree(s);
return;
OpenPOWER on IntegriCloud