Ghidra is a software reverse engineering (SRE) framework
GP-1754 - Updated Symbol Edit Dialog to not allow namespaces editing with a blank name
dragonmacher2f278bd4ca2d
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/AddEditDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/AddEditDialog.javaindex 632f88416a..b075eb3037 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/AddEditDialog.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/AddEditDialog.java@@ -153,6 +153,11 @@ public class AddEditDialog extends DialogComponentProvider {}String symbolName = symbolPath.getName();+ if (StringUtils.isBlank(symbolName)) {+ // this is the case of having a namespace without a name, such as "Namespace::"+ setStatusText("Name cannot be blank while changing namespace");+ return;+ }// see if the user specified a namespace path and if so, then get the// new namespace name from that path@@ -178,6 +183,7 @@ public class AddEditDialog extends DialogComponentProvider {return;}+ cmd = new CompoundCmd(symbol == null ? "Add Label" : "Edit Label");if (primaryCheckBox.isEnabled() && primaryCheckBox.isSelected()) {cmd.add(new SetLabelPrimaryCmd(addr, symbolName, parent));}diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/label/AddEditDialoglTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/label/AddEditDialoglTest.javaindex d3ede93d7c..7311dbd800 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/label/AddEditDialoglTest.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/label/AddEditDialoglTest.java@@ -754,6 +754,32 @@ public class AddEditDialoglTest extends AbstractGhidraHeadedIntegrationTest {assertEquals(nsName, parentNs.getName());}+ @Test+ public void testSetNamespace_NamespaceWithoutFunctionName() throws Exception {++ //+ // Test that we can cannot create a new namespace and clear a symbol name using this form:+ // "Namespace::"+ //+ // A blank name is a signal to reset to a default name, but we do not currently support+ // changing a namespace and resetting the name in the same operation.+ //++ String functionName = "FUN_010065f0";+ Symbol functionSymbol = getSymbol(functionName);+ Namespace originalNamespace = functionSymbol.getParentNamespace();+ editLabel(functionSymbol);+ String nsName = "NewNamespace";+ setText(nsName + Namespace.DELIMITER);+ pressOk();+ assertTrue("Rename unsuccesful", dialog.isShowing());+ assertStatusText("Name cannot be blank while changing namespace");++ Symbol newFunction = functionSymbol;+ Namespace parentNs = newFunction.getParentNamespace();+ assertSame(originalNamespace, parentNs);+ }+//==================================================================================================// Private Methods//==================================================================================================