Skip to content

Commit

Permalink
Fix for Bug#85223 (25656020), MYSQLSQLXML SETSTRING CRASH.
Browse files Browse the repository at this point in the history
  • Loading branch information
soklakov committed Nov 19, 2021
1 parent 97b5d11 commit bc45d35
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Version 8.0.28

- Fix for Bug#85223 (25656020), MYSQLSQLXML SETSTRING CRASH.

- Fix for Bug#84365 (33425867), INSERT..VALUE with VALUES function lead to a StringIndexOutOfBoundsException.

- Fix for Bug#105211 (33468860), class java.time.LocalDate cannot be cast to class java.sql.Date.
Expand Down
2 changes: 1 addition & 1 deletion src/main/user-impl/java/com/mysql/cj/jdbc/MysqlSQLXML.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ protected String readerToString(Reader reader) throws SQLException {

protected synchronized Reader serializeAsCharacterStream() throws SQLException {
checkClosed();
if (this.workingWithResult) {
if (this.workingWithResult || this.owningResultSet == null) {
// figure out what kind of result
if (this.stringRep != null) {
return new StringReader(this.stringRep);
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/testsuite/regression/StatementRegressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11873,4 +11873,29 @@ public void testBug84365() throws Exception {
assertFalse(this.rs.next());
}
}

/**
* Test fix for Bug#85223 (25656020), MYSQLSQLXML SETSTRING CRASH.
*
* @throws Exception
*/
@Test
public void testBug85223() throws Exception {
Properties props = new Properties();
props.setProperty(PropertyKey.sslMode.getKeyName(), SslMode.DISABLED.name());
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");

String elementString = "<Person ID=\"1\"><PersonType>M</PersonType><FirstName>FName</FirstName><LastName>LName</LastName></Person>";
Connection con = getConnectionWithProps(props);
PreparedStatement pst = con.prepareStatement("SELECT ExtractValue(?,?) as val1");
SQLXML xml = con.createSQLXML();
xml.setString(elementString);
pst.setSQLXML(1, xml);
pst.setString(2, "/Person/LastName");
pst.execute();
this.rs = pst.getResultSet();
this.rs.next();
String value = this.rs.getString(1);
assertEquals("LName", value);
}
}

0 comments on commit bc45d35

Please sign in to comment.