Skip to content

Ghidra is a software reverse engineering (SRE) framework

fixed bug in organization nodes when inserting into mixed case groups

ghidravoreaa86f74b98d5
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symboltree/nodes/OrganizationNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symboltree/nodes/OrganizationNode.java
index eb9b3d0a62..d70c1b2c4f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symboltree/nodes/OrganizationNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symboltree/nodes/OrganizationNode.java
@@ -300,7 +300,7 @@ public class OrganizationNode extends SymbolTreeNode {
public int compareTo(GTreeNode node) {
if (!(node instanceof OrganizationNode)) {
String nodeName = node.getName();
- if (nodeName.regionMatches(true, 0, baseName, 0, baseName.length())) {
+ if (nodeName.regionMatches(false, 0, baseName, 0, baseName.length())) {
// Consider this node equal to the org node, as the symbol node will be a child
// of this org node. This allows us to quickly search for the parent of any
// given symbol node.
diff --git a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/symboltree/nodes/OrganizationNodeTest.java b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/symboltree/nodes/OrganizationNodeTest.java
index 787bc0bf2c..50e7985e9b 100644
--- a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/symboltree/nodes/OrganizationNodeTest.java
+++ b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/symboltree/nodes/OrganizationNodeTest.java
@@ -84,6 +84,37 @@ public class OrganizationNodeTest extends AbstractDockingTest {
assertEquals("CAF", caGroup.getChild(5).getName());
}
+ @Test
+ public void testInsertNodeMixedCase() {
+ List<GTreeNode> nodeList = nodes("Aaa", "AAa", "Aab", "AAb", "AAc", "Aac", "AAd", "Aad",
+ "AAe", "Aae", "AAf", "Aaf", "Z");
+ List<GTreeNode> result = organize(nodeList, 3);
+ // this in two nodes, the group starting with "A" and the node "Z" (Z) was added so that
+ // an "A" group would be a top level group
+
+ OrganizationNode groupA = (OrganizationNode) result.get(0);
+ assertEquals("A", groupA.getName());
+
+ assertEquals(2, groupA.getChildCount());
+ OrganizationNode groupAa = (OrganizationNode) groupA.getChild(0);
+ OrganizationNode groupAA = (OrganizationNode) groupA.getChild(1);
+ assertEquals("Aa", groupAa.getName());
+ assertEquals("AA", groupAA.getName());
+ assertEquals(6, groupAa.getChildCount());
+ assertEquals(6, groupAA.getChildCount());
+
+ groupA.insertNode(node("AAaz"));
+ // node should be added to AA group
+ assertEquals(6, groupAa.getChildCount());
+ assertEquals(7, groupAA.getChildCount());
+
+ groupA.insertNode(node("Aaaz"));
+ // node should be added to Aa group
+ assertEquals(7, groupAa.getChildCount());
+ assertEquals(7, groupAA.getChildCount());
+
+ }
+
@Test
public void testManySameLabels() {
List<GTreeNode> nodeList =