Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 468a60b

Browse files
author
Chris Board
committed
Bug fix with 5.7 authentication and other issues
An issue on MySQL 5.7 was found with the authentication packet where a malformed packet would be sent. Fixed issue authentication seed data would be hardcoded to utf-8 instead of following the server language connection settings.
1 parent 85294ea commit 468a60b

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

AndroidMySQLConnector/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ group 'com.BoardiesITSolutions'
2525

2626

2727
android {
28-
compileSdkVersion 27
28+
compileSdkVersion 28
2929
defaultConfig {
3030
//applicationId "com.BoardiesITSolutions.AndroidMySQLConnector"
3131
minSdkVersion 19
32-
targetSdkVersion 27
33-
versionCode 9
32+
targetSdkVersion 28
33+
versionCode 14
3434
versionName "0.23"
3535
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3636
}
@@ -88,7 +88,7 @@ def getArtifactFullPath() {
8888

8989
dependencies {
9090
implementation fileTree(dir: 'libs', include: ['*.jar'])
91-
implementation 'com.android.support:appcompat-v7:27.1.1'
91+
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
9292
testImplementation 'junit:junit:4.12'
9393
androidTestImplementation 'com.android.support.test:runner:1.0.2'
9494
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

AndroidMySQLConnector/src/main/java/com/BoardiesITSolutions/AndroidMySQLConnector/PacketManager/AuthResponse.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private void createAuthenticationPacket() throws IOException
9696
String authSalt2 = this.mysqlConn.getAuthSalt2();
9797
String seed = this.mysqlConn.getAuthSalt() + this.mysqlConn.getAuthSalt2();
9898
//String updateSeed = this.seed.substring(0, 20);
99-
byte[] bytes = seed.getBytes(Charset.forName("UTF-8"));
99+
byte[] bytes = seed.getBytes(charset);
100100
String temp = readString(bytes);
101101
byte[] password = scramblePassword(this.mysqlConn.getPassword(), temp);
102102

@@ -111,9 +111,13 @@ private void createAuthenticationPacket() throws IOException
111111
//any error either we receive an EOF packet but running show processlist from the server itself
112112
//shows unauthenticated user. Therefore, if we're not connecting to a default database
113113
//add the null terminator to the password, if we are using a default database don't add the null terminator
114+
//but this also only appears to be required on certain MySQL Versions.
114115
if ((this.mysqlConn.getDatabase() == null) || this.mysqlConn.getDatabase().length() == 0)
115116
{
116-
dataOutPacket.writeByte(0); //Write the null terminator
117+
if (!mysqlConn.getServerVersion().startsWith("5.7"))
118+
{
119+
dataOutPacket.writeByte(0); //Write the null terminator
120+
}
117121
}
118122

119123
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ buildscript {
1616
google()
1717
}
1818
dependencies {
19-
classpath 'com.android.tools.build:gradle:3.1.3'
19+
classpath 'com.android.tools.build:gradle:3.1.4'
2020
if (!publishToMavenLocal) {
2121
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
2222
}

0 commit comments

Comments
 (0)