瀏覽代碼

DirectoryFileSystem: Updated ValidatePath to verify that path starts with a blackslash

Tal Aloni 8 年之前
父節點
當前提交
38b9829d6a
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      SMBServer/DirectoryFileSystem/DirectoryFileSystem.cs

+ 7 - 2
SMBServer/DirectoryFileSystem/DirectoryFileSystem.cs

@@ -276,9 +276,14 @@ namespace SMBServer
 
         private void ValidatePath(string path)
         {
-            if (path.StartsWith(@"..\") || path.Contains(@"\..\"))
+            if (path != String.Empty && !path.StartsWith(@"\"))
             {
-                throw new UnauthorizedAccessException("Given path is not allowed");
+                throw new ArgumentException("Path must start with a backslash");
+            }
+
+            if (path.Contains(@"\..\"))
+            {
+                throw new ArgumentException("Given path is not allowed");
             }
         }