From 38b9829d6a3d37a61e31847737bb16c2fd5669fb Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 3 Feb 2017 00:23:29 +0200 Subject: [PATCH] DirectoryFileSystem: Updated ValidatePath to verify that path starts with a blackslash --- SMBServer/DirectoryFileSystem/DirectoryFileSystem.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SMBServer/DirectoryFileSystem/DirectoryFileSystem.cs b/SMBServer/DirectoryFileSystem/DirectoryFileSystem.cs index 25744fd..d3efcf6 100644 --- a/SMBServer/DirectoryFileSystem/DirectoryFileSystem.cs +++ b/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"); } }