View | Details | Raw Unified | Return to bug 1999
Collapse All | Expand All

(-)sshconnect.c (-12 / +31 lines)
Lines 419-424 ssh_connect(const char *host, struct soc Link Here
419
	return 0;
419
	return 0;
420
}
420
}
421
421
422
static void
423
send_client_banner(int connection_out, int minor1)
424
{
425
	char buf[256];
426
427
	/* Send our own protocol version identification. */
428
	snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s",
429
	    compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
430
	    compat20 ? PROTOCOL_MINOR_2 : minor1,
431
	    SSH_VERSION, compat20 ? "\r\n" : "\n");
432
	if (roaming_atomicio(vwrite, connection_out, buf, strlen(buf))
433
	    != strlen(buf))
434
		fatal("write: %.100s", strerror(errno));
435
	client_version_string = xstrdup(buf);
436
	chop(client_version_string);
437
	debug("Local version string %.100s", client_version_string);
438
}
439
422
/*
440
/*
423
 * Waits for the server identification string, and sends our own
441
 * Waits for the server identification string, and sends our own
424
 * identification string.
442
 * identification string.
Lines 430-436 ssh_exchange_identification(int timeout_ Link Here
430
	int remote_major, remote_minor, mismatch;
448
	int remote_major, remote_minor, mismatch;
431
	int connection_in = packet_get_connection_in();
449
	int connection_in = packet_get_connection_in();
432
	int connection_out = packet_get_connection_out();
450
	int connection_out = packet_get_connection_out();
433
	int minor1 = PROTOCOL_MINOR_1;
451
	int minor1 = PROTOCOL_MINOR_1, client_sent = 0;
434
	u_int i, n;
452
	u_int i, n;
435
	size_t len;
453
	size_t len;
436
	int fdsetsz, remaining, rc;
454
	int fdsetsz, remaining, rc;
Lines 440-445 ssh_exchange_identification(int timeout_ Link Here
440
	fdsetsz = howmany(connection_in + 1, NFDBITS) * sizeof(fd_mask);
458
	fdsetsz = howmany(connection_in + 1, NFDBITS) * sizeof(fd_mask);
441
	fdset = xcalloc(1, fdsetsz);
459
	fdset = xcalloc(1, fdsetsz);
442
460
461
	/*
462
	 * If we are SSH2-only then we can send the banner immediately and
463
	 * save a round-trip.
464
	 */
465
	if (options.protocol == SSH_PROTO_2) {
466
		enable_compat20();
467
		send_client_banner(connection_out, 0);
468
		client_sent = 1;
469
	}
470
443
	/* Read other side's version identification. */
471
	/* Read other side's version identification. */
444
	remaining = timeout_ms;
472
	remaining = timeout_ms;
445
	for (n = 0;;) {
473
	for (n = 0;;) {
Lines 542-559 ssh_exchange_identification(int timeout_ Link Here
542
		fatal("Protocol major versions differ: %d vs. %d",
570
		fatal("Protocol major versions differ: %d vs. %d",
543
		    (options.protocol & SSH_PROTO_2) ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
571
		    (options.protocol & SSH_PROTO_2) ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
544
		    remote_major);
572
		    remote_major);
545
	/* Send our own protocol version identification. */
573
	if (!client_sent)
546
	snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s",
574
		send_client_banner(connection_out, minor1);
547
	    compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
548
	    compat20 ? PROTOCOL_MINOR_2 : minor1,
549
	    SSH_VERSION, compat20 ? "\r\n" : "\n");
550
	if (roaming_atomicio(vwrite, connection_out, buf, strlen(buf))
551
	    != strlen(buf))
552
		fatal("write: %.100s", strerror(errno));
553
	client_version_string = xstrdup(buf);
554
	chop(client_version_string);
555
	chop(server_version_string);
575
	chop(server_version_string);
556
	debug("Local version string %.100s", client_version_string);
557
}
576
}
558
577
559
/* defaults to 'no' */
578
/* defaults to 'no' */
(-)compat.c (+2 lines)
Lines 43-48 int datafellows = 0; Link Here
43
void
43
void
44
enable_compat20(void)
44
enable_compat20(void)
45
{
45
{
46
	if (compat20)
47
		return;
46
	debug("Enabling compatibility mode for protocol 2.0");
48
	debug("Enabling compatibility mode for protocol 2.0");
47
	compat20 = 1;
49
	compat20 = 1;
48
}
50
}

Return to bug 1999