X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/8f203108d91b3aef5a379a6d49f6cb2a546eebbc..c52ee7f941fa3a31171c58879c11c9a744c25e93:/ssh.c diff --git a/ssh.c b/ssh.c index a1b0deb0..295d0e68 100644 --- a/ssh.c +++ b/ssh.c @@ -127,6 +127,7 @@ static void ssh_gotdata(unsigned char *data, int datalen) { static long len, biglen, to_read; static unsigned char *p; static int i, pad; + static unsigned long realcrc, gotcrc; crBegin; while (1) { @@ -186,6 +187,15 @@ static void ssh_gotdata(unsigned char *data, int datalen) { pktin.type = pktin.data[pad]; pktin.body = pktin.data+pad+1; + realcrc = crc32(pktin.data, biglen-4); + gotcrc = (pktin.data[biglen-4] << 24); + gotcrc |= (pktin.data[biglen-3] << 16); + gotcrc |= (pktin.data[biglen-2] << 8); + gotcrc |= (pktin.data[biglen-1] << 0); + if (gotcrc != realcrc) { + fatalbox("Incorrect CRC received on packet"); + } + if (pktin.type == SSH_MSG_DEBUG) { /* FIXME: log it */ } else if (pktin.type == SSH_MSG_IGNORE) { @@ -500,7 +510,8 @@ static void ssh_protocol(unsigned char *in, int inlen, int ispkt) { exit(0); break; default: - if (c >= ' ' && c <= '~' && pos < 40) { + if (((c >= ' ' && c <= '~') || + ((unsigned char)c >= 160)) && pos < 40) { username[pos++] = c; c_write(&c, 1); } @@ -584,7 +595,8 @@ static void ssh_protocol(unsigned char *in, int inlen, int ispkt) { exit(0); break; default: - if (c >= ' ' && c <= '~' && pos < 40) + if (((c >= ' ' && c <= '~') || + ((unsigned char)c >= 160)) && pos < 40) password[pos++] = c; break; }