diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/ExportTrie.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/ExportTrie.java index 7d03f5fee5..18416292e6 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/ExportTrie.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/ExportTrie.java @@ -89,9 +89,14 @@ public class ExportTrie { * @throws IOException if there was an IO-related error */ private void parseTrie() throws IOException { + Set visited = new HashSet<>(); + visited.add(0); LinkedList remainingNodes = parseNode("", 0); while(!remainingNodes.isEmpty()) { Node parent = remainingNodes.removeFirst(); + if (!visited.add(parent.offset())) { + continue; // skip already-visited offsets + } LinkedList children = parseNode(parent.name, parent.offset); for (Node child : children) { remainingNodes.add(new Node(parent.name + child.name, child.offset)); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/BrowserLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/util/BrowserLoader.java index c29d4c4019..fa6c593957 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/util/BrowserLoader.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/util/BrowserLoader.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. @@ -159,17 +159,31 @@ public class BrowserLoader { } String urlString = option.getUrlReplacementString(); + String urlArg; if (urlString.equals(ManualViewerCommandWrappedOption.HTTP_URL_REPLACEMENT_STRING) || fileURL == null) { - argumentList.add(url.toExternalForm()); + urlArg = url.toExternalForm(); } else if (urlString.equals(ManualViewerCommandWrappedOption.FILE_URL_REPLACEMENT_STRING)) { - argumentList.add(fileURL.toExternalForm()); + urlArg = fileURL.toExternalForm(); } else { - argumentList.add(new File(fileURL.getFile()).getAbsolutePath()); + urlArg = new File(fileURL.getFile()).getAbsolutePath(); } + // If launching "cmd.exe /c start URL", surround the URL with double quotes to protect + // against special characters being misinterpreted by the shell. + // NOTE: If not already present, a double-quoted title must be inserted since the URL + // argument that follows will start with a double quote. + if (commandArguments.length >= 2 && commandArguments[0].equalsIgnoreCase("/c") && + commandArguments[1].equalsIgnoreCase("start")) { + if (commandArguments.length == 2) { + argumentList.add("\"Title\""); + } + urlArg = '"' + urlArg + '"'; + } + argumentList.add(urlArg); + return argumentList.toArray(new String[argumentList.size()]); }