Added security manager checks.

This commit is contained in:
jfrijters 2011-10-22 06:33:39 +00:00
Родитель 2e222f1600
Коммит 90f06f8f71
1 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -418,11 +418,21 @@ final class NetPath extends AbstractPath
{ {
return this; return this;
} }
// System.getProperty("user.dir") will trigger the specified security check
return new NetPath(fs, cli.System.IO.Path.GetFullPath(cli.System.IO.Path.Combine(System.getProperty("user.dir"), path))); return new NetPath(fs, cli.System.IO.Path.GetFullPath(cli.System.IO.Path.Combine(System.getProperty("user.dir"), path)));
} }
public Path toRealPath(LinkOption... options) throws IOException public Path toRealPath(LinkOption... options) throws IOException
{ {
SecurityManager sm = System.getSecurityManager();
if (sm != null)
{
sm.checkRead(path);
if (!isAbsolute())
{
sm.checkPropertyAccess("user.dir");
}
}
return new NetPath(fs, toRealPathImpl(path)); return new NetPath(fs, toRealPathImpl(path));
} }
@ -487,6 +497,15 @@ final class NetPath extends AbstractPath
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} }
SecurityManager sm = System.getSecurityManager();
if (sm != null)
{
sm.checkRead(path);
if (subtree)
{
sm.checkRead(path + cli.System.IO.Path.DirectorySeparatorChar + '-');
}
}
return ((NetFileSystem.NetWatchService)watcher).register(this, create, delete, modify, overflow, subtree); return ((NetFileSystem.NetWatchService)watcher).register(this, create, delete, modify, overflow, subtree);
} }