summaryrefslogtreecommitdiff
path: root/sshconnect.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-05-26 12:23:44 +1000
committerDamien Miller <djm@mindrot.org>2005-05-26 12:23:44 +1000
commitb253cc42136649e3eac80e02667f8fbc1e43baaa (patch)
treee3824a905c7b12e4901e60e87ecdc968228e645e /sshconnect.c
parent02e754f1f01470c11a175a0d07381361afe37fff (diff)
- avsm@cvs.openbsd.org 2005/05/24 17:32:44
[atomicio.c atomicio.h authfd.c monitor_wrap.c msg.c scp.c sftp-client.c] [ssh-keyscan.c sshconnect.c] Switch atomicio to use a simpler interface; it now returns a size_t (containing number of bytes read/written), and indicates error by returning 0. EOF is signalled by errno==EPIPE. Typical use now becomes: if (atomicio(read, ..., len) != len) err(1,"read"); ok deraadt@, cloder@, djm@
Diffstat (limited to 'sshconnect.c')
-rw-r--r--sshconnect.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sshconnect.c b/sshconnect.c
index 07703cf77..b79cead5d 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15#include "includes.h" 15#include "includes.h"
16RCSID("$OpenBSD: sshconnect.c,v 1.162 2005/03/10 22:01:06 deraadt Exp $"); 16RCSID("$OpenBSD: sshconnect.c,v 1.163 2005/05/24 17:32:44 avsm Exp $");
17 17
18#include <openssl/bn.h> 18#include <openssl/bn.h>
19 19
@@ -426,14 +426,15 @@ ssh_exchange_identification(void)
426 int connection_out = packet_get_connection_out(); 426 int connection_out = packet_get_connection_out();
427 int minor1 = PROTOCOL_MINOR_1; 427 int minor1 = PROTOCOL_MINOR_1;
428 428
429 /* Read other side\'s version identification. */ 429 /* Read other side's version identification. */
430 for (;;) { 430 for (;;) {
431 for (i = 0; i < sizeof(buf) - 1; i++) { 431 for (i = 0; i < sizeof(buf) - 1; i++) {
432 int len = atomicio(read, connection_in, &buf[i], 1); 432 size_t len = atomicio(read, connection_in, &buf[i], 1);
433 if (len < 0) 433
434 fatal("ssh_exchange_identification: read: %.100s", strerror(errno)); 434 if (len != 1 && errno == EPIPE)
435 if (len != 1)
436 fatal("ssh_exchange_identification: Connection closed by remote host"); 435 fatal("ssh_exchange_identification: Connection closed by remote host");
436 else if (len != 1)
437 fatal("ssh_exchange_identification: read: %.100s", strerror(errno));
437 if (buf[i] == '\r') { 438 if (buf[i] == '\r') {
438 buf[i] = '\n'; 439 buf[i] = '\n';
439 buf[i + 1] = 0; 440 buf[i + 1] = 0;