List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:February 15 2000 1:57pm
Subject:Bad handshake problem with java and MySQL 3.22.32
View as plain text  
Hi!

The protocol security fix in MySQL 3.22.32 caused a bug in the MM
driver to show its ugly face:  (I haven't had time to verify if the twz
driver has the same problem)

For connections where one uses passwords and the passwords is not 8
bytes longs, you will get a Bad Handshake error.

Here follows a patch that should fix this until the drivers are
updated.

Regards,
Monty


*** /tmp/Util.java	Tue Feb 15 15:31:21 2000
--- Util.java	Tue Feb 15 15:31:51 2000
***************
*** 45,53 ****
          long seed1 = (pw[0] ^ msg[0]) % max;
          long seed2 = (pw[1] ^ msg[1]) % max;
  
!         char[] chars = new char[Passwd.length()];
  
!         for (int i = 0; i < Passwd.length(); i++) {
              seed1 = (seed1 * 3 + seed2) % max;
              seed2 = (seed1 + seed2 + 33) % max;
              d = (double)seed1 / (double)max;
--- 45,53 ----
          long seed1 = (pw[0] ^ msg[0]) % max;
          long seed2 = (pw[1] ^ msg[1]) % max;
  
!         char[] chars = new char[Seed.length()];
  
!         for (int i = 0; i < Seed.length(); i++) {
              seed1 = (seed1 * 3 + seed2) % max;
              seed2 = (seed1 + seed2 + 33) % max;
              d = (double)seed1 / (double)max;
***************
*** 60,66 ****
          d = (double)seed1 / (double)max;
          b = (byte)java.lang.Math.floor(d * 31);
  
!         for (int i = 0; i < Passwd.length(); i++)
              chars[i] ^= (char)b;
  
          return new String(chars);
--- 60,66 ----
          d = (double)seed1 / (double)max;
          b = (byte)java.lang.Math.floor(d * 31);
  
!         for (int i = 0; i < Seed.length(); i++)
              chars[i] ^= (char)b;
  
          return new String(chars);
***************
*** 82,90 ****
          s1 = nr;
          s2 = nr/2;
  
!         char[] chars = new char[Passwd.length()];
  
!         for (int i = 0; i< Passwd.length(); i++) {
              s1 = (s1 * 3 + s2) % max;
              s2 = (s1 + s2 + 33) % max;
              d = (double)s1 / max;
--- 82,90 ----
          s1 = nr;
          s2 = nr/2;
  
!         char[] chars = new char[Seed.length()];
  
!         for (int i = 0; i< Seed.length(); i++) {
              s1 = (s1 * 3 + s2) % max;
              s2 = (s1 + s2 + 33) % max;
              d = (double)s1 / max;
Thread
Bad handshake problem with java and MySQL 3.22.32Michael Widenius15 Feb