sprintf(vstring, "SSH-%s-PuTTY\n", (ssh_versioncmp(version, "1.5") <= 0 ? version : "1.5")); sprintf(vlog, "We claim version: %s", vstring); vlog[strcspn(vlog, "\r\n")] = '\0'; logevent(vlog); s_write(vstring, strlen(vstring));
if (ssh_versioncmp(version, "1.99") >= 0) {  char *verstring = "SSH-2.0-PuTTY"; SHA_Init(&exhash);  sha_string(&exhash, verstring, strlen(verstring)); sha_string(&exhash, vstring, strcspn(vstring, "\r\n")); sprintf(vstring, "%s\n", verstring); sprintf(vlog, "We claim version: %s", verstring); logevent(vlog); logevent("Using SSH protocol version 2"); s_write(vstring, strlen(vstring)); ssh_protocol = ssh2_protocol; s_rdpkt = ssh2_rdpkt; } else {  sprintf(vstring, "SSH-%s-PuTTY\n", (ssh_versioncmp(version, "1.5") <= 0 ? version : "1.5")); sprintf(vlog, "We claim version: %s", vstring); vlog[strcspn(vlog, "\r\n")] = '\0'; logevent(vlog); logevent("Using SSH protocol version 1"); s_write(vstring, strlen(vstring)); ssh_protocol = ssh1_protocol; s_rdpkt = ssh1_rdpkt; }
static int do_ssh_init(void) {    char c, *vsp;    char version[10];    char vstring[80];    char vlog[sizeof(vstring)+20];    int i;#ifdef FWHACK    i = 0;    while (s_read(&c, 1) == 1) {	if (c == 'S' && i < 2) i++;	else if (c == 'S' && i == 2) i = 2;	else if (c == 'H' && i == 2) break;	else i = 0;    }#else    if (s_read(&c,1) != 1 || c != 'S') return 0;    if (s_read(&c,1) != 1 || c != 'S') return 0;    if (s_read(&c,1) != 1 || c != 'H') return 0;#endif    strcpy(vstring, "SSH-");    vsp = vstring+4;    if (s_read(&c,1) != 1 || c != '-') return 0;    i = 0;    while (1) {	if (s_read(&c,1) != 1)	    return 0;	if (vsp < vstring+sizeof(vstring)-1)	    *vsp++ = c;	if (i >= 0) {	    if (c == '-') {		version[i] = '\0';		i = -1;	    } else if (i < sizeof(version)-1)		version[i++] = c;	}	else if (c == '\n')	    break;    }    *vsp = 0;    sprintf(vlog, "Server version: %s", vstring);    vlog[strcspn(vlog, "\r\n")] = '\0';    logevent(vlog);    sprintf(vstring, "SSH-%s-PuTTY\n",	    (ssh_versioncmp(version, "1.5") <= 0 ? version : "1.5"));    sprintf(vlog, "We claim version: %s", vstring);    vlog[strcspn(vlog, "\r\n")] = '\0';    logevent(vlog);    s_write(vstring, strlen(vstring));    return 1;}