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

Commit 0f0416f

Browse files
author
Chris Board
committed
Fixes issue with certain blob data columns
Fixed an issue where if a blob column had an empty string, the query packet response processor would misinterpret a byte equalling 0x00 as a MySQL EOF packet and therefore corrupting and not retrieving all rows within the table.
1 parent 4ea4b2b commit 0f0416f

File tree

8 files changed

+72
-11
lines changed

8 files changed

+72
-11
lines changed
0 Bytes
Binary file not shown.

.idea/jarRepositories.xml

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AndroidMySQLConnector/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ else
2020
}
2121

2222
archivesBaseName="AndroidMySQLConnector"
23-
version '0.39'
23+
version '0.40'
2424
group 'com.BoardiesITSolutions'
2525

2626

@@ -30,8 +30,8 @@ android {
3030
//applicationId "com.BoardiesITSolutions.AndroidMySQLConnector"
3131
minSdkVersion 19
3232
targetSdkVersion 29
33-
versionCode 27
34-
versionName "0.37"
33+
versionCode 28
34+
versionName "0.40"
3535
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3636
}
3737
buildTypes {

AndroidMySQLConnector/src/main/java/com/BoardiesITSolutions/AndroidMySQLConnector/ColumnDefinition.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.BoardiesITSolutions.AndroidMySQLConnector;
22

3+
import java.math.BigInteger;
4+
5+
import static java.lang.Math.abs;
6+
37
public class ColumnDefinition
48
{
59
public enum ColumnType {

AndroidMySQLConnector/src/main/java/com/BoardiesITSolutions/AndroidMySQLConnector/MySQLRow.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public MySQLRow()
1515
this.columnAndRowValue = new HashMap<>();
1616
}
1717

18+
public int getSizeOfHash()
19+
{
20+
return this.columnAndRowValue.size();
21+
}
22+
1823
public void addRowValue(ColumnDefinition columnDefinition, String rowValue)
1924
{
2025
this.columnAndRowValue.put(columnDefinition, rowValue);

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private void processPacketData()
7373

7474
int columnLength = this.mysqlConn.getMysqlIO().fromByteArray((byte[])this.mysqlConn.getMysqlIO().extractData(4));
7575

76-
int columnType = (byte)this.mysqlConn.getMysqlIO().extractData(1);
76+
int columnType = (byte)this.mysqlConn.getMysqlIO().extractData(1) & 0xff;
7777

7878
int flags = this.mysqlConn.getMysqlIO().fromByteArray((byte[])this.mysqlConn.getMysqlIO().extractData(2));
7979

@@ -155,7 +155,7 @@ private void processPacketData()
155155
for (; currentColumn < numberOfFields; currentColumn++)
156156
{
157157
packetType = this.mysqlConn.getMysqlIO().readCurrentByteWithoutShift() & 0xff;
158-
if (Helpers.getMySQLPacketTypeFromIntWithoutShift(packetType) == Helpers.MYSQL_PACKET_TYPE.MYSQL_OK_PACKET ||
158+
if ((numberOfFields == currentColumn-1) && Helpers.getMySQLPacketTypeFromIntWithoutShift(packetType) == Helpers.MYSQL_PACKET_TYPE.MYSQL_OK_PACKET ||
159159
Helpers.getMySQLPacketTypeFromIntWithoutShift(packetType) == Helpers.MYSQL_PACKET_TYPE.MYSQL_EOF_PACKET)
160160
{
161161

@@ -164,10 +164,14 @@ private void processPacketData()
164164
//We've got an EOF packet and the remaining data in the socket data is less than 9 so this is a true 0xFE.
165165
//You sometimes get an 0xFE packet when its actually a len encoded integer. As this is a true EOF packet
166166
//we can break from the loop as we have everything we need
167-
finishedProcessingColumns = true;
167+
168168
//We've created a row object in case we needed it, but as we've detected as an EOF packet,
169169
//set the row to null so it doesn't get added to to the resultset.
170-
row = null;
170+
if (row.getSizeOfHash() == 0)
171+
{
172+
row = null;
173+
finishedProcessingColumns = true;
174+
}
171175
break;
172176
}
173177
//We've got an EOF packet but there's actually more data so not a true EOF packet so shift 9 bytes
@@ -181,8 +185,11 @@ private void processPacketData()
181185
{
182186
if ((this.mysqlConn.getMysqlIO().getSocketDataLength() - this.mysqlConn.getMysqlIO().getCurrentBytesRead()) < 9)
183187
{
184-
finishedProcessingColumns = true;
185-
row = null;
188+
if (row.getSizeOfHash() == 0)
189+
{
190+
row = null;
191+
finishedProcessingColumns = true;
192+
}
186193
break;
187194
}
188195
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
buildscript {
55

66
ext {
7-
publishToMavenLocal = false
7+
publishToMavenLocal = true
88
}
99

1010
repositories {

0 commit comments

Comments
 (0)