Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
835fb4e9
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
835fb4e9
编写于
10月 10, 2019
作者:
A
andrew
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8213429: Windows file handling redux
8167646: Better invalid FilePermission Reviewed-by: mbalao
上级
b267884f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
107 addition
and
0 deletion
+107
-0
src/share/classes/java/io/FilePermission.java
src/share/classes/java/io/FilePermission.java
+37
-0
src/share/classes/sun/misc/Launcher.java
src/share/classes/sun/misc/Launcher.java
+3
-0
test/java/io/FilePermission/Invalid.java
test/java/io/FilePermission/Invalid.java
+67
-0
未找到文件。
src/share/classes/java/io/FilePermission.java
浏览文件 @
835fb4e9
...
...
@@ -25,12 +25,16 @@
package
java.io
;
import
java.net.URI
;
import
java.nio.file.InvalidPathException
;
import
java.security.*
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.ArrayList
;
import
java.util.Vector
;
import
java.util.Collections
;
import
sun.nio.fs.DefaultFileSystemProvider
;
import
sun.security.util.SecurityConstants
;
/**
...
...
@@ -152,6 +156,8 @@ public final class FilePermission extends Permission implements Serializable {
private
transient
String
cpath
;
private
transient
boolean
invalid
;
// whether input path is invalid
// static Strings used by init(int mask)
private
static
final
char
RECURSIVE_CHAR
=
'-'
;
private
static
final
char
WILD_CHAR
=
'*'
;
...
...
@@ -173,6 +179,14 @@ public final class FilePermission extends Permission implements Serializable {
private
static
final
long
serialVersionUID
=
7930732926638008763L
;
/**
* Always use the internal default file system, in case it was modified
* with java.nio.file.spi.DefaultFileSystemProvider.
*/
private
static
final
java
.
nio
.
file
.
FileSystem
builtInFS
=
DefaultFileSystemProvider
.
create
()
.
getFileSystem
(
URI
.
create
(
"file:///"
));
/**
* initialize a FilePermission object. Common to all constructors.
* Also called during de-serialization.
...
...
@@ -199,6 +213,20 @@ public final class FilePermission extends Permission implements Serializable {
return
;
}
// Validate path by platform's default file system
// Note: this check does not apply during FilePermission
// class initialization.
if
(
builtInFS
!=
null
)
{
try
{
String
name
=
cpath
.
endsWith
(
"*"
)
?
cpath
.
substring
(
0
,
cpath
.
length
()
-
1
)
+
"-"
:
cpath
;
builtInFS
.
getPath
(
new
File
(
name
).
getPath
());
}
catch
(
InvalidPathException
ipe
)
{
invalid
=
true
;
return
;
}
}
// store only the canonical cpath if possible
cpath
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
String
>()
{
public
String
run
()
{
...
...
@@ -335,6 +363,12 @@ public final class FilePermission extends Permission implements Serializable {
* @return the effective mask
*/
boolean
impliesIgnoreMask
(
FilePermission
that
)
{
if
(
this
==
that
)
{
return
true
;
}
if
(
this
.
invalid
||
that
.
invalid
)
{
return
false
;
}
if
(
this
.
directory
)
{
if
(
this
.
recursive
)
{
// make sure that.path is longer then path so
...
...
@@ -395,6 +429,9 @@ public final class FilePermission extends Permission implements Serializable {
FilePermission
that
=
(
FilePermission
)
obj
;
if
(
this
.
invalid
||
that
.
invalid
)
{
return
false
;
}
return
(
this
.
mask
==
that
.
mask
)
&&
this
.
cpath
.
equals
(
that
.
cpath
)
&&
(
this
.
directory
==
that
.
directory
)
&&
...
...
src/share/classes/sun/misc/Launcher.java
浏览文件 @
835fb4e9
...
...
@@ -85,6 +85,9 @@ public class Launcher {
// Finally, install a security manager if requested
String
s
=
System
.
getProperty
(
"java.security.manager"
);
if
(
s
!=
null
)
{
// init FileSystem machinery before SecurityManager installation
sun
.
nio
.
fs
.
DefaultFileSystemProvider
.
create
();
SecurityManager
sm
=
null
;
if
(
""
.
equals
(
s
)
||
"default"
.
equals
(
s
))
{
sm
=
new
java
.
lang
.
SecurityManager
();
...
...
test/java/io/FilePermission/Invalid.java
0 → 100644
浏览文件 @
835fb4e9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @test
* @bug 8167646
* @summary Better invalid FilePermission
* @library /lib/testlibrary
*/
import
jdk.testlibrary.Asserts
;
import
java.io.FilePermission
;
public
class
Invalid
{
public
static
void
main
(
String
args
[])
throws
Exception
{
// Normal
FilePermission
fp
=
new
FilePermission
(
"a"
,
"read"
);
// Invalid
FilePermission
fp1
=
new
FilePermission
(
"a\000"
,
"read"
);
FilePermission
fp2
=
new
FilePermission
(
"a\000"
,
"read"
);
FilePermission
fp3
=
new
FilePermission
(
"b\000"
,
"read"
);
// Invalid equals to itself
Asserts
.
assertEQ
(
fp1
,
fp1
);
// and not equals to anything else, including other invalid ones
Asserts
.
assertNE
(
fp
,
fp1
);
Asserts
.
assertNE
(
fp1
,
fp
);
Asserts
.
assertNE
(
fp1
,
fp2
);
Asserts
.
assertNE
(
fp1
,
fp3
);
// Invalid implies itself
Asserts
.
assertTrue
(
fp1
.
implies
(
fp1
));
// and not implies or implied by anything else, including other
// invalid ones
Asserts
.
assertFalse
(
fp
.
implies
(
fp1
));
Asserts
.
assertFalse
(
fp1
.
implies
(
fp
));
Asserts
.
assertFalse
(
fp1
.
implies
(
fp2
));
Asserts
.
assertFalse
(
fp1
.
implies
(
fp3
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录