Skip to content

Commit 389ef07

Browse files
author
Roberto E. Garcia
committed
Merge branch '6.8' into 6.9
2 parents a6a7e0c + adf1054 commit 389ef07

22 files changed

+62
-51
lines changed

CHANGES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
6.9.7
2-
- Changed default SSL mode to Preferred in connection string. Now the server connections will be using SSL if server allows it by default but it's possible to override this configuration.
2+
- Changed default SSL mode to Preferred in connection string. Now the server connections will be using SSL if server allows it by default but it's possible to override this configuration.
3+
- Changed handshake process to use bytes instead of encoded strings.
34

45

56
6.9.6

Source/MySql.Data/Driver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Driver(MySqlConnectionStringBuilder settings)
7777
if (encoding == null)
7878
throw new MySqlException(Resources.DefaultEncodingNotFound);
7979
connectionString = settings;
80-
serverCharSet = "utf-8";
80+
serverCharSet = "utf8";
8181
serverCharSetIndex = -1;
8282
maxPacketSize = 1024;
8383
handler = new NativeDriver(this);

Source/MySql.Data/MySqlPacket.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2004, 2011, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2004, 2015, Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -354,17 +354,26 @@ public string ReadString()
354354

355355
public string ReadString(Encoding theEncoding)
356356
{
357-
byte[] bits = buffer.GetBuffer();
357+
byte[] bytes = ReadStringAsBytes();
358+
string s = theEncoding.GetString(bytes, 0, bytes.Length);
359+
return s;
360+
}
361+
362+
public byte[] ReadStringAsBytes()
363+
{
364+
byte[] readBytes;
365+
byte[] tempBuffer = buffer.GetBuffer();
358366
int end = (int)buffer.Position;
359367

360368
while (end < (int)buffer.Length &&
361-
bits[end] != 0 && (int)bits[end] != -1)
369+
tempBuffer[end] != 0 && (int)tempBuffer[end] != -1)
362370
end++;
363371

364-
string s = theEncoding.GetString(bits,
365-
(int)buffer.Position, end - (int)buffer.Position);
372+
readBytes = new byte[end - buffer.Position];
373+
Array.Copy(tempBuffer, (int)buffer.Position, readBytes, 0, (int)(end - buffer.Position));
366374
buffer.Position = end + 1;
367-
return s;
375+
376+
return readBytes;
368377
}
369378

370379
#endregion

Source/MySql.Data/NativeDriver.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal class NativeDriver : IDriver
5050
{
5151
private DBVersion version;
5252
private int threadId;
53-
protected String encryptionSeed;
53+
protected byte[] encryptionSeed;
5454
protected ServerStatusFlags serverStatus;
5555
protected MySqlStream stream;
5656
protected Stream baseStream;
@@ -227,7 +227,8 @@ public void Open()
227227
if (!owner.isFabric && !version.isAtLeast(5, 0, 0))
228228
throw new NotSupportedException(Resources.ServerTooOld);
229229
threadId = packet.ReadInteger(4);
230-
encryptionSeed = packet.ReadString();
230+
231+
byte[] seedPart1 = packet.ReadStringAsBytes();
231232

232233
maxSinglePacket = (256 * 256 * 256) - 1;
233234

@@ -247,8 +248,10 @@ public void Open()
247248
serverCaps |= (ClientFlags)(serverCapsHigh << 16);
248249

249250
packet.Position += 11;
250-
string seedPart2 = packet.ReadString();
251-
encryptionSeed += seedPart2;
251+
byte[] seedPart2 = packet.ReadStringAsBytes();
252+
encryptionSeed = new byte[seedPart1.Length + seedPart2.Length];
253+
seedPart1.CopyTo(encryptionSeed, 0);
254+
seedPart2.CopyTo(encryptionSeed, seedPart1.Length);
252255

253256
string authenticationMethod = "";
254257
if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
@@ -488,13 +491,11 @@ public void Authenticate(string authMethod, bool reset)
488491
{
489492
if (authMethod != null)
490493
{
491-
byte[] seedBytes = Encoding.GetBytes(encryptionSeed);
492-
493494
// Integrated security is a shortcut for windows auth
494495
if (Settings.IntegratedSecurity)
495496
authMethod = "authentication_windows_client";
496497

497-
authPlugin = MySqlAuthenticationPlugin.GetPlugin(authMethod, this, seedBytes);
498+
authPlugin = MySqlAuthenticationPlugin.GetPlugin(authMethod, this, encryptionSeed);
498499
}
499500
authPlugin.Authenticate(reset);
500501
}

Tests/MySql.Data.Tests.Stress/StressTestsPipe.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013, 2014 Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2013, 2015 Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -36,7 +36,7 @@ public class StressTestsPipe : StressTests
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format("protocol=pipe;pipe name={0}", st.pipeName);
39+
return string.Format("protocol=pipe;pipe name={0};ssl mode=none;", st.pipeName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests.Stress/StressTestsPipeCompressed.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013, 2014 Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2013, 2015 Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -36,7 +36,7 @@ public class StressTestsPipeCompressed : StressTests
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format("protocol=pipe;pipe name={0};compress=true", st.pipeName);
39+
return string.Format("protocol=pipe;pipe name={0};compress=true;ssl mode=none;", st.pipeName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests.Stress/StressTestsSharedMemory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013, 2014 Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2013, 2015 Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -36,7 +36,7 @@ public class StressTestsSharedMemory : StressTests
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format("protocol=memory; shared memory name={0}", st.memoryName);
39+
return string.Format("protocol=memory; shared memory name={0};ssl mode=none;", st.memoryName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests.Stress/StressTestsSharedMemoryCompressed.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013, 2014 Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2013, 2015 Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -36,7 +36,7 @@ public class StressTestsSharedMemoryCompressed : StressTests
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format("protocol=memory; shared memory name={0};compress=true", st.memoryName);
39+
return string.Format("protocol=memory; shared memory name={0};compress=true;ssl mode=none;", st.memoryName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests/BlobTestsPipe.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2013, 2015 Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -39,7 +39,7 @@ public class BlobTestsPipe : BlobTests
3939
{
4040
protected override string OnGetConnectionStringInfo()
4141
{
42-
return String.Format("protocol=pipe;pipe name={0}", st.pipeName);
42+
return String.Format("protocol=pipe;pipe name={0};ssl mode=none;", st.pipeName);
4343
}
4444
}
4545
#endif

Tests/MySql.Data.Tests/BlobTestsPipeCompressed.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013 Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2013, 2015 Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -39,7 +39,7 @@ public class BlobTestsPipeCompressed : BlobTests
3939
{
4040
protected override string OnGetConnectionStringInfo()
4141
{
42-
return String.Format("protocol=pipe;pipe name={0};compress=true", st.pipeName);
42+
return String.Format("protocol=pipe;pipe name={0};compress=true;ssl mode=none;", st.pipeName);
4343
}
4444
}
4545
#endif

0 commit comments

Comments
 (0)