BUG_SSH2_DERIVEKEY is apparently only present in SSH 2.0.11 and
[u/mdw/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index 2df7110..588c8c3 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -1073,7 +1073,7 @@ static int ssh2_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
             logevent(buf);
            sfree(buf);
             buf = dupprintf("Disconnection message text: %n%.*s",
-                           msglen, &nowlen, ssh->pktin.data + 14);
+                           &nowlen, msglen, ssh->pktin.data + 14);
             logevent(buf);
             bombout((ssh,"Server sent disconnect message\ntype %d (%s):\n\"%s\"",
                      reason,
@@ -1776,9 +1776,9 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring)
 
     if (cfg.sshbug_hmac2 == BUG_ON ||
        (cfg.sshbug_hmac2 == BUG_AUTO &&
-        (!strncmp(imp, "2.1.0", 5) || !strncmp(imp, "2.0.", 4) ||
-         !strncmp(imp, "2.2.0", 5) || !strncmp(imp, "2.3.0", 5) ||
-         !strncmp(imp, "2.1 ", 4)))) {
+        (wc_match("2.1.0*", imp) || wc_match("2.0.*", imp) ||
+         wc_match("2.2.0*", imp) || wc_match("2.3.0*", imp) ||
+         wc_match("2.1 *", imp)))) {
        /*
         * These versions have the HMAC bug.
         */
@@ -1788,7 +1788,7 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring)
 
     if (cfg.sshbug_derivekey2 == BUG_ON ||
        (cfg.sshbug_derivekey2 == BUG_AUTO &&
-        (!strncmp(imp, "2.0.", 4)))) {
+        (wc_match("2.0.0*", imp) || wc_match("2.0.1[01]*", imp) ))) {
        /*
         * These versions have the key-derivation bug (failing to
         * include the literal shared secret in the hashes that
@@ -1800,8 +1800,8 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring)
 
     if (cfg.sshbug_rsapad2 == BUG_ON ||
        (cfg.sshbug_rsapad2 == BUG_AUTO &&
-        ((!strncmp(imp, "OpenSSH_2.", 10) && imp[10]>='5' && imp[10]<='9') ||
-         (!strncmp(imp, "OpenSSH_3.", 10) && imp[10]>='0' && imp[10]<='2')))){
+        (wc_match("OpenSSH_2.[5-9]*", imp) ||
+         wc_match("OpenSSH_3.[0-2]*", imp)))) {
        /*
         * These versions have the SSH2 RSA padding bug.
         */
@@ -1811,7 +1811,7 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring)
 
     if (cfg.sshbug_dhgex2 == BUG_ON) {
        /*
-        * These versions have the SSH2 DH GEX bug.
+        * User specified the SSH2 DH GEX bug.
         */
        ssh->remote_bugs |= BUG_SSH2_DH_GEX;
        logevent("We believe remote version has SSH2 DH group exchange bug");
@@ -4375,8 +4375,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
        /* Load the pub half of cfg.keyfile so we notice if it's in Pageant */
        if (*cfg.keyfile) {
            int keytype;
-           logeventf(ssh->frontend,
-                     "Reading private key file \"%.150s\"", cfg.keyfile);
+           logeventf(ssh, "Reading private key file \"%.150s\"", cfg.keyfile);
            keytype = key_type(cfg.keyfile);
            if (keytype == SSH_KEYTYPE_SSH2) {
                s->publickey_blob =
@@ -4384,8 +4383,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
                                         &s->publickey_bloblen);
            } else {
                char *msgbuf;
-               logeventf(ssh->frontend,
-                         "Unable to use this key file (%s)",
+               logeventf(ssh, "Unable to use this key file (%s)",
                          key_type_to_str(keytype));
                msgbuf = dupprintf("Unable to use key file \"%.150s\""
                                   " (%s)\r\n", cfg.keyfile,