diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/ExecutableNameBSimFilterType.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/ExecutableNameBSimFilterType.java index 710e75a253..01e345bc29 100644 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/ExecutableNameBSimFilterType.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/ExecutableNameBSimFilterType.java @@ -17,6 +17,8 @@ package ghidra.features.bsim.gui.filters; import java.sql.SQLException; +import org.postgresql.core.Utils; + import ghidra.features.bsim.query.client.IDSQLResolution; import ghidra.features.bsim.query.client.SQLEffects; import ghidra.features.bsim.query.description.ExecutableRecord; @@ -39,7 +41,9 @@ public class ExecutableNameBSimFilterType extends BSimFilterType { throws SQLException { effect.setExeTable(); StringBuilder buf = new StringBuilder(); - buf.append("exetable.name_exec = '").append(atom.value).append('\''); + buf.append("exetable.name_exec = '"); + Utils.escapeLiteral(buf, atom.value, true); + buf.append('\''); effect.addWhere(this, buf.toString()); } diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/NotExecutableNameBSimFilterType.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/NotExecutableNameBSimFilterType.java index 1d986fcd9f..6498b6d4f8 100644 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/NotExecutableNameBSimFilterType.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/NotExecutableNameBSimFilterType.java @@ -17,6 +17,8 @@ package ghidra.features.bsim.gui.filters; import java.sql.SQLException; +import org.postgresql.core.Utils; + import ghidra.features.bsim.query.client.IDSQLResolution; import ghidra.features.bsim.query.client.SQLEffects; import ghidra.features.bsim.query.description.ExecutableRecord; @@ -38,7 +40,9 @@ public class NotExecutableNameBSimFilterType extends BSimFilterType { throws SQLException { effect.setExeTable(); StringBuilder buf = new StringBuilder(); - buf.append("exetable.name_exec != '").append(atom.value).append('\''); + buf.append("exetable.name_exec != '"); + Utils.escapeLiteral(buf, atom.value, true); + buf.append('\''); effect.addWhere(this, buf.toString()); } diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/PathStartsBSimFilterType.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/PathStartsBSimFilterType.java index acecb6fa43..c3d06725d5 100644 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/PathStartsBSimFilterType.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/filters/PathStartsBSimFilterType.java @@ -17,6 +17,8 @@ package ghidra.features.bsim.gui.filters; import java.sql.SQLException; +import org.postgresql.core.Utils; + import ghidra.features.bsim.query.client.IDSQLResolution; import ghidra.features.bsim.query.client.SQLEffects; import ghidra.features.bsim.query.description.ExecutableRecord; @@ -40,7 +42,9 @@ public class PathStartsBSimFilterType extends BSimFilterType { effect.setExeTable(); effect.setPathTable(); StringBuilder buf = new StringBuilder(); - buf.append("position( \'").append(atom.value).append("\' in pathtable.val) = 1"); + buf.append("position( '"); + Utils.escapeLiteral(buf, atom.value, true); + buf.append("' in pathtable.val) = 1"); effect.addWhere(this, buf.toString()); } } diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java index 9b6b74eda9..cb529d6f18 100755 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java @@ -22,6 +22,8 @@ import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; +import org.postgresql.core.Utils; + import generic.lsh.vector.LSHVector; import generic.lsh.vector.WeightedLSHCosineVectorFactory; import ghidra.features.bsim.query.*; @@ -104,15 +106,10 @@ public final class PostgresFunctionDatabase private void changePassword(Connection c, String username, char[] newPassword) throws SQLException { StringBuilder buffer = new StringBuilder(); - buffer.append("ALTER ROLE \""); - buffer.append(username); - buffer.append("\" WITH PASSWORD '"); - for (char ch : newPassword) { - if (ch == '\'') { - buffer.append(ch); // Escape single quote by appending it twice - } - buffer.append(ch); - } + buffer.append("ALTER ROLE "); + Utils.escapeIdentifier(buffer, username); + buffer.append(" WITH PASSWORD '"); + Utils.escapeLiteral(buffer, new String(newPassword), true); buffer.append('\''); // Don't think jdbc does anything to this statement to encrypt password before sending it. // The connection with the server SHOULD be under SSL at this point @@ -194,11 +191,12 @@ public final class PostgresFunctionDatabase BSimServerInfo defaultServerInfo = new BSimServerInfo(DBType.postgres, serverInfo.getUserInfo(), serverInfo.getServerName(), serverInfo.getPort(), DEFAULT_DATABASE_NAME); - String createdbstring = "CREATE DATABASE \"" + serverInfo.getDBName() + '"'; + StringBuilder sb = new StringBuilder("CREATE DATABASE "); + Utils.escapeIdentifier(sb, serverInfo.getDBName()); BSimPostgresDataSource defaultDs = BSimPostgresDBConnectionManager.getDataSource(defaultServerInfo); try (Connection db = defaultDs.getConnection(); Statement st = db.createStatement()) { - st.executeUpdate(createdbstring); + st.executeUpdate(sb.toString()); postgresDs.initializeFrom(defaultDs); } } @@ -264,8 +262,9 @@ public final class PostgresFunctionDatabase try (Connection defaultDb = defaultDs.getConnection(); Statement defaultSt = defaultDb.createStatement()) { - try (ResultSet rs = defaultSt.executeQuery( - "SELECT 1 FROM pg_database WHERE datname='" + serverInfo.getDBName() + "'")) { + StringBuilder sb = new StringBuilder("SELECT 1 FROM pg_database WHERE datname= "); + Utils.escapeIdentifier(sb, serverInfo.getDBName()); + try (ResultSet rs = defaultSt.executeQuery(sb.toString())) { if (!rs.next()) { return; // database does not exist } @@ -292,7 +291,9 @@ public final class PostgresFunctionDatabase postgresDs.dispose(); // disconnect before dropping database Msg.info(this, "Dropping BSim postgresql database: " + serverInfo); - defaultSt.executeUpdate("DROP DATABASE \"" + serverInfo.getDBName() + '"'); + sb = new StringBuilder("DROP DATABASE "); + Utils.escapeIdentifier(sb, serverInfo.getDBName()); + defaultSt.executeUpdate(sb.toString()); } finally { // ensure diff --git a/Ghidra/Features/GhidraServer/data/serial.filter b/Ghidra/Features/GhidraServer/data/serial.filter index 99022f5455..711e2a6c6b 100644 --- a/Ghidra/Features/GhidraServer/data/serial.filter +++ b/Ghidra/Features/GhidraServer/data/serial.filter @@ -39,6 +39,7 @@ sun.security.x509.X509CertImpl; java.rmi.server.UID; java.rmi.server.ObjID; +[Ljava.rmi.server.ObjID; java.rmi.dgc.DGC; java.rmi.dgc.Lease; diff --git a/Ghidra/Processors/HCS12/src/main/java/ghidra/app/plugin/core/analysis/HCS12ConventionAnalyzer.java b/Ghidra/Processors/HCS12/src/main/java/ghidra/app/plugin/core/analysis/HCS12ConventionAnalyzer.java index b2c0f2f61a..5ef162ae20 100644 --- a/Ghidra/Processors/HCS12/src/main/java/ghidra/app/plugin/core/analysis/HCS12ConventionAnalyzer.java +++ b/Ghidra/Processors/HCS12/src/main/java/ghidra/app/plugin/core/analysis/HCS12ConventionAnalyzer.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,10 +51,11 @@ public class HCS12ConventionAnalyzer extends AbstractAnalyzer { @Override public boolean canAnalyze(Program program) { - // Only analyze HCS12 Programs + // Only analyze HCS-12 / HCS-12X Programs Processor processor = program.getLanguage().getProcessor(); + boolean canDo = "HCS-12".equals(processor.toString()) || + "HCS-12X".equals(processor.toString()); - boolean canDo = processor.equals(Processor.findOrPossiblyCreateProcessor("HCS12")); if (canDo) { xgate = program.getRegister("XGATE"); } diff --git a/build.gradle b/build.gradle index f30dba4f12..b45a63732c 100644 --- a/build.gradle +++ b/build.gradle @@ -339,6 +339,20 @@ def getCurrentDateTimeLong() { return formattedDate } +/********************************************************************************* + * Returns the project object from the given projectDependency + *********************************************************************************/ +def getDependencyProject(p, projectDependency) { + if (projectDependency.hasProperty("path")) { + // Supported by Gradle 8.11 and later + return p.project(projectDependency.path) + } + else { + // Supported in Gradle 8.5, removed in Gradle 9 + return projectDependency.dependencyProject + } +} + /********************************************************************************* * Returns true if 'project' has a direct or transitive API project dependency * on the project with path 'targetPath'. The 'targetPath' should be specified @@ -355,11 +369,11 @@ boolean hasApiProjectDependency(Project project, String targetPath) { .allDependencies .withType(org.gradle.api.artifacts.ProjectDependency) - if (apiDeps.any { it.dependencyProject.path == targetPath }) { + if (apiDeps.any { getDependencyProject(p, it).path == targetPath }) { return true } - return apiDeps.any { dep -> walk(dep.dependencyProject) } + return apiDeps.any { walk(getDependencyProject(p, it)) } } walk(project)