Skip to content

Commit adf1054

Browse files
author
Roberto E. Garcia
committed
Merge branch '6.7' into 6.8
2 parents ffb6765 + 034be5f commit adf1054

22 files changed

+64
-50
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
6.8.7
2+
- Changed handshake process to use bytes instead of encoded strings.
3+
4+
15
6.8.6
26
- 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.
37

Source/MySql.Data/Driver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public Driver(MySqlConnectionStringBuilder settings)
7676
if (encoding == null)
7777
throw new MySqlException(Resources.DefaultEncodingNotFound);
7878
connectionString = settings;
79-
serverCharSet = "utf-8";
79+
serverCharSet = "utf8";
8080
serverCharSetIndex = -1;
8181
maxPacketSize = 1024;
8282
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;
@@ -226,7 +226,8 @@ public void Open()
226226
if (!version.isAtLeast(5, 0, 0))
227227
throw new NotSupportedException(Resources.ServerTooOld);
228228
threadId = packet.ReadInteger(4);
229-
encryptionSeed = packet.ReadString();
229+
230+
byte[] seedPart1 = packet.ReadStringAsBytes();
230231

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

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

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

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

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

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

Tests/MySql.Data.Tests/BlobTestsSharedMemory.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 BlobTestsSharedMemory : BlobTests
3939
{
4040
protected override string OnGetConnectionStringInfo()
4141
{
42-
return String.Format("protocol=memory; shared memory name={0}", st.memoryName);
42+
return String.Format("protocol=memory; shared memory name={0};ssl mode=none;", st.memoryName);
4343
}
4444
}
4545
#endif

Tests/MySql.Data.Tests/BlobTestsSharedMemoryCompressed.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 BlobTestsSharedMemoryCompressed : BlobTests
3939
{
4040
protected override string OnGetConnectionStringInfo()
4141
{
42-
return String.Format("protocol=memory; shared memory name={0};compress=true", st.memoryName);
42+
return String.Format("protocol=memory; shared memory name={0};compress=true;ssl mode=none;", st.memoryName);
4343
}
4444
}
4545
#endif

Tests/MySql.Data.Tests/MySqlCommandTestsPipe.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
@@ -38,7 +38,7 @@ public class MySqlCommandTestsPipe : MySqlCommandTests
3838
{
3939
protected override string OnGetConnectionStringInfo()
4040
{
41-
return String.Format("protocol=namedpipe;pipe name={0}", st.pipeName);
41+
return String.Format("protocol=namedpipe;pipe name={0};ssl mode=none;", st.pipeName);
4242
}
4343
}
4444
#endif

Tests/MySql.Data.Tests/MySqlCommandTestsPipeCompressed.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
@@ -38,7 +38,7 @@ public class MySqlCommandTestsPipeCompressed : MySqlCommandTests
3838
{
3939
protected override string OnGetConnectionStringInfo()
4040
{
41-
return String.Format("protocol=namedpipe;pipe name={0};compress=true", st.pipeName);
41+
return String.Format("protocol=namedpipe;pipe name={0};compress=true;ssl mode=none;", st.pipeName);
4242
}
4343
}
4444
#endif

Tests/MySql.Data.Tests/MySqlCommandTestsSharedMemory.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
@@ -38,7 +38,7 @@ public class MySqlCommandTestsSharedMemory : MySqlCommandTests
3838
{
3939
protected override string OnGetConnectionStringInfo()
4040
{
41-
return String.Format("protocol=sharedmemory; shared memory name={0}", st.memoryName);
41+
return String.Format("protocol=sharedmemory; shared memory name={0};ssl mode=none;", st.memoryName);
4242
}
4343
}
4444
#endif

Tests/MySql.Data.Tests/MySqlCommandTestsSharedMemoryCompressed.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
@@ -38,7 +38,7 @@ public class MySqlCommandTestsSharedMemoryCompressed : MySqlCommandTests
3838
{
3939
protected override string OnGetConnectionStringInfo()
4040
{
41-
return String.Format("protocol=sharedmemory; shared memory name={0};compress=true", st.memoryName);
41+
return String.Format("protocol=sharedmemory; shared memory name={0};compress=true;ssl mode=none;", st.memoryName);
4242
}
4343
}
4444
#endif

Tests/MySql.Data.Tests/PreparedStatementsPipe.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
@@ -36,7 +36,7 @@ public class PreparedStatementsPipe : PreparedStatements
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format(";ignore prepare=false;protocol=pipe;pipe name={0}", st.pipeName);
39+
return string.Format(";ignore prepare=false;protocol=pipe;pipe name={0};ssl mode=none;", st.pipeName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests/PreparedStatementsPipeCompressed.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
@@ -36,7 +36,7 @@ public class PreparedStatementsPipeCompressed : PreparedStatements
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format(";ignore prepare=false;protocol=pipe;pipe name={0};compress=true", st.pipeName);
39+
return string.Format(";ignore prepare=false;protocol=pipe;pipe name={0};compress=true;ssl mode=none;", st.pipeName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests/PreparedStatementsSharedMemory.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
@@ -36,7 +36,7 @@ public class PreparedStatementsSharedMemory : PreparedStatements
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format(";ignore prepare=false;protocol=memory; shared memory name={0}", st.memoryName);
39+
return string.Format(";ignore prepare=false;protocol=memory; shared memory name={0};ssl mode=none;", st.memoryName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests/PreparedStatementsSharedMemoryCompressed.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
@@ -36,7 +36,7 @@ public class PreparedStatementsSharedMemoryCompressed : PreparedStatements
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format(";ignore prepare=false;protocol=memory; shared memory name={0};compress=true", st.memoryName);
39+
return string.Format(";ignore prepare=false;protocol=memory; shared memory name={0};compress=true;ssl mode=none;", st.memoryName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests/TimeoutAndCancelPipe.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
@@ -36,7 +36,7 @@ public class TimeoutAndCancelPipe : TimeoutAndCancel
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format("protocol=namedpipe;pipe name={0}", st.pipeName);
39+
return string.Format("protocol=namedpipe;pipe name={0};ssl mode=none;", st.pipeName);
4040
}
4141
}
4242
}

Tests/MySql.Data.Tests/TimeoutAndCancelSharedMemory.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
@@ -36,7 +36,7 @@ public class TimeoutAndCancelSharedMemory : TimeoutAndCancel
3636
{
3737
protected override string OnGetConnectionStringInfo()
3838
{
39-
return string.Format("protocol=sharedmemory; shared memory name={0}", st.memoryName);
39+
return string.Format("protocol=sharedmemory; shared memory name={0};ssl mode=none;", st.memoryName);
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)