1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00

Bah. Ben points out that SSH_1_ version strings should still end in

\n, and also that `\r' and `\n' don't mean what I think they mean on
all compilers (Mac reverses them).

[originally from svn r4941]
This commit is contained in:
Simon Tatham 2004-12-01 15:34:12 +00:00
parent 4c31b113a6
commit 9731b1425d

12
ssh.c
View File

@ -2149,7 +2149,7 @@ static int do_ssh_init(Ssh ssh, unsigned char c)
ssh->rdpkt2_state.incoming_sequence = 0; ssh->rdpkt2_state.incoming_sequence = 0;
s->vstring[s->vslen] = 0; s->vstring[s->vslen] = 0;
s->vstring[strcspn(s->vstring, "\r\n")] = '\0';/* remove EOL chars */ s->vstring[strcspn(s->vstring, "\015\012")] = '\0';/* remove EOL chars */
{ {
char *vlog; char *vlog;
vlog = snewn(20 + s->vslen, char); vlog = snewn(20 + s->vslen, char);
@ -2184,13 +2184,13 @@ static int do_ssh_init(Ssh ssh, unsigned char c)
/* /*
* Construct a v2 version string. * Construct a v2 version string.
*/ */
verstring = dupprintf("SSH-2.0-%s\r\n", sshver); verstring = dupprintf("SSH-2.0-%s\015\012", sshver);
ssh->version = 2; ssh->version = 2;
} else { } else {
/* /*
* Construct a v1 version string. * Construct a v1 version string.
*/ */
verstring = dupprintf("SSH-%s-%s\r\n", verstring = dupprintf("SSH-%s-%s\012",
(ssh_versioncmp(s->version, "1.5") <= 0 ? (ssh_versioncmp(s->version, "1.5") <= 0 ?
s->version : "1.5"), s->version : "1.5"),
sshver); sshver);
@ -2205,9 +2205,9 @@ static int do_ssh_init(Ssh ssh, unsigned char c)
*/ */
SHA_Init(&ssh->exhashbase); SHA_Init(&ssh->exhashbase);
sha_string(&ssh->exhashbase, verstring, sha_string(&ssh->exhashbase, verstring,
strcspn(verstring, "\r\n")); strcspn(verstring, "\015\012"));
sha_string(&ssh->exhashbase, s->vstring, sha_string(&ssh->exhashbase, s->vstring,
strcspn(s->vstring, "\r\n")); strcspn(s->vstring, "\015\012"));
/* /*
* Initialise SSHv2 protocol. * Initialise SSHv2 protocol.
@ -2224,7 +2224,7 @@ static int do_ssh_init(Ssh ssh, unsigned char c)
ssh->s_rdpkt = ssh1_rdpkt; ssh->s_rdpkt = ssh1_rdpkt;
} }
logeventf(ssh, "We claim version: %.*s", logeventf(ssh, "We claim version: %.*s",
strcspn(verstring, "\r\n"), verstring); strcspn(verstring, "\015\012"), verstring);
sk_write(ssh->s, verstring, strlen(verstring)); sk_write(ssh->s, verstring, strlen(verstring));
sfree(verstring); sfree(verstring);
} }