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

This commit is contained in:
Tal Aloni 2017-02-03 00:23:29 +02:00
parent efbf28036e
commit 38b9829d6a

View file

@ -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");
}
}