summaryrefslogtreecommitdiff
path: root/sshconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshconnect.c')
-rw-r--r--sshconnect.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/sshconnect.c b/sshconnect.c
index bf00159b3..835ca7b3a 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10#include "includes.h" 10#include "includes.h"
11RCSID("$OpenBSD: sshconnect.c,v 1.74 2000/05/17 16:57:02 markus Exp $"); 11RCSID("$OpenBSD: sshconnect.c,v 1.76 2000/06/17 20:30:10 markus Exp $");
12 12
13#include <openssl/bn.h> 13#include <openssl/bn.h>
14#include <openssl/dsa.h> 14#include <openssl/dsa.h>
@@ -314,23 +314,28 @@ ssh_exchange_identification()
314 int connection_out = packet_get_connection_out(); 314 int connection_out = packet_get_connection_out();
315 315
316 /* Read other side\'s version identification. */ 316 /* Read other side\'s version identification. */
317 for (i = 0; i < sizeof(buf) - 1; i++) { 317 for (;;) {
318 int len = read(connection_in, &buf[i], 1); 318 for (i = 0; i < sizeof(buf) - 1; i++) {
319 if (len < 0) 319 int len = atomicio(read, connection_in, &buf[i], 1);
320 fatal("ssh_exchange_identification: read: %.100s", strerror(errno)); 320 if (len < 0)
321 if (len != 1) 321 fatal("ssh_exchange_identification: read: %.100s", strerror(errno));
322 fatal("ssh_exchange_identification: Connection closed by remote host"); 322 if (len != 1)
323 if (buf[i] == '\r') { 323 fatal("ssh_exchange_identification: Connection closed by remote host");
324 buf[i] = '\n'; 324 if (buf[i] == '\r') {
325 buf[i + 1] = 0; 325 buf[i] = '\n';
326 continue; /**XXX wait for \n */ 326 buf[i + 1] = 0;
327 continue; /**XXX wait for \n */
328 }
329 if (buf[i] == '\n') {
330 buf[i + 1] = 0;
331 break;
332 }
327 } 333 }
328 if (buf[i] == '\n') { 334 buf[sizeof(buf) - 1] = 0;
329 buf[i + 1] = 0; 335 if (strncmp(buf, "SSH-", 4) == 0)
330 break; 336 break;
331 } 337 debug("ssh_exchange_identification: %s", buf);
332 } 338 }
333 buf[sizeof(buf) - 1] = 0;
334 server_version_string = xstrdup(buf); 339 server_version_string = xstrdup(buf);
335 340
336 /* 341 /*