Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1696 Fix UNC pathname handling (github #3912)

dev747368002d04c42fe7
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GFileImpl.java b/Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GFileImpl.java
index b369796fa9..acfd707276 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GFileImpl.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GFileImpl.java
@@ -76,6 +76,12 @@ public class GFileImpl implements GFile {
public static GFileImpl fromPathString(GFileSystem fileSystem, GFile parent, String path,
FSRL fsrl, boolean isDirectory, long length) {
String[] split = path.split(FSUtilities.SEPARATOR);
+ if (split.length >= 3 && split[0].isEmpty() && split[1].isEmpty() && !split[2].isEmpty()) {
+ // The path was in UNC format, either //unc or \\unc.
+ // Put a unc prefix "//" back into the element that has the unc name. The leading empty
+ // elements will be skipped when building the parentage.
+ split[2] = "//" + split[2];
+ }
for (int i = 0; i < split.length - 1; ++i) {
if (split[i].length() == 0) {
continue;