Bugzilla – Attachment 2175 Details for
Bug 1999
When speaking v2, send client version first to avoid long delay with some proxies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Refactor, always send client banner first for protocol=2
ssh2-client-banner.diff (text/plain), 3.12 KB, created by
Damien Miller
on 2012-07-20 11:02:44 AEST
(
hide
)
Description:
Refactor, always send client banner first for protocol=2
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2012-07-20 11:02:44 AEST
Size:
3.12 KB
patch
obsolete
>Index: sshconnect.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/sshconnect.c,v >retrieving revision 1.234 >diff -u -p -r1.234 sshconnect.c >--- sshconnect.c 24 May 2011 07:15:47 -0000 1.234 >+++ sshconnect.c 20 Jul 2012 00:56:33 -0000 >@@ -419,6 +419,24 @@ ssh_connect(const char *host, struct soc > return 0; > } > >+static void >+send_client_banner(int connection_out, int minor1) >+{ >+ char buf[256]; >+ >+ /* Send our own protocol version identification. */ >+ snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s", >+ compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1, >+ compat20 ? PROTOCOL_MINOR_2 : minor1, >+ SSH_VERSION, compat20 ? "\r\n" : "\n"); >+ if (roaming_atomicio(vwrite, connection_out, buf, strlen(buf)) >+ != strlen(buf)) >+ fatal("write: %.100s", strerror(errno)); >+ client_version_string = xstrdup(buf); >+ chop(client_version_string); >+ debug("Local version string %.100s", client_version_string); >+} >+ > /* > * Waits for the server identification string, and sends our own > * identification string. >@@ -430,7 +448,7 @@ ssh_exchange_identification(int timeout_ > int remote_major, remote_minor, mismatch; > int connection_in = packet_get_connection_in(); > int connection_out = packet_get_connection_out(); >- int minor1 = PROTOCOL_MINOR_1; >+ int minor1 = PROTOCOL_MINOR_1, client_sent = 0; > u_int i, n; > size_t len; > int fdsetsz, remaining, rc; >@@ -440,6 +458,16 @@ ssh_exchange_identification(int timeout_ > fdsetsz = howmany(connection_in + 1, NFDBITS) * sizeof(fd_mask); > fdset = xcalloc(1, fdsetsz); > >+ /* >+ * If we are SSH2-only then we can send the banner immediately and >+ * save a round-trip. >+ */ >+ if (options.protocol == SSH_PROTO_2) { >+ enable_compat20(); >+ send_client_banner(connection_out, 0); >+ client_sent = 1; >+ } >+ > /* Read other side's version identification. */ > remaining = timeout_ms; > for (n = 0;;) { >@@ -542,18 +570,9 @@ ssh_exchange_identification(int timeout_ > fatal("Protocol major versions differ: %d vs. %d", > (options.protocol & SSH_PROTO_2) ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1, > remote_major); >- /* Send our own protocol version identification. */ >- snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s", >- compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1, >- compat20 ? PROTOCOL_MINOR_2 : minor1, >- SSH_VERSION, compat20 ? "\r\n" : "\n"); >- if (roaming_atomicio(vwrite, connection_out, buf, strlen(buf)) >- != strlen(buf)) >- fatal("write: %.100s", strerror(errno)); >- client_version_string = xstrdup(buf); >- chop(client_version_string); >+ if (!client_sent) >+ send_client_banner(connection_out, minor1); > chop(server_version_string); >- debug("Local version string %.100s", client_version_string); > } > > /* defaults to 'no' */ >Index: compat.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/compat.c,v >retrieving revision 1.79 >diff -u -p -r1.79 compat.c >--- compat.c 23 Sep 2011 07:45:05 -0000 1.79 >+++ compat.c 20 Jul 2012 00:56:33 -0000 >@@ -43,6 +43,8 @@ int datafellows = 0; > void > enable_compat20(void) > { >+ if (compat20) >+ return; > debug("Enabling compatibility mode for protocol 2.0"); > compat20 = 1; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1999
:
2145
| 2175