Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_nashorn
提交
c858eb64
D
dragonwell8_nashorn
项目概览
openanolis
/
dragonwell8_nashorn
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_nashorn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c858eb64
编写于
2月 25, 2014
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8030197: Nashorn: Object.defineProperty() can be lured to change fixed NaN property
Reviewed-by: attila, jlaskey
上级
90b066af
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
96 addition
and
1 deletion
+96
-1
src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java
.../nashorn/internal/objects/AccessorPropertyDescriptor.java
+12
-0
src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java
src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java
+13
-0
src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java
...k/nashorn/internal/objects/GenericPropertyDescriptor.java
+17
-0
src/jdk/nashorn/internal/runtime/PropertyDescriptor.java
src/jdk/nashorn/internal/runtime/PropertyDescriptor.java
+7
-0
src/jdk/nashorn/internal/runtime/ScriptObject.java
src/jdk/nashorn/internal/runtime/ScriptObject.java
+1
-1
test/script/basic/JDK-8030197.js
test/script/basic/JDK-8030197.js
+46
-0
未找到文件。
src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java
浏览文件 @
c858eb64
...
...
@@ -184,6 +184,18 @@ public final class AccessorPropertyDescriptor extends ScriptObject implements Pr
return
ACCESSOR
;
}
@Override
public
boolean
hasAndEquals
(
final
PropertyDescriptor
otherDesc
)
{
if
(!
(
otherDesc
instanceof
AccessorPropertyDescriptor
))
{
return
false
;
}
final
AccessorPropertyDescriptor
other
=
(
AccessorPropertyDescriptor
)
otherDesc
;
return
(!
has
(
CONFIGURABLE
)
||
sameValue
(
configurable
,
other
.
configurable
))
&&
(!
has
(
ENUMERABLE
)
||
sameValue
(
enumerable
,
other
.
enumerable
))
&&
(!
has
(
GET
)
||
sameValue
(
get
,
other
.
get
))
&&
(!
has
(
SET
)
||
sameValue
(
set
,
other
.
set
));
}
@Override
public
boolean
equals
(
final
Object
obj
)
{
if
(
this
==
obj
)
{
...
...
src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java
浏览文件 @
c858eb64
...
...
@@ -171,6 +171,19 @@ public final class DataPropertyDescriptor extends ScriptObject implements Proper
return
DATA
;
}
@Override
public
boolean
hasAndEquals
(
final
PropertyDescriptor
otherDesc
)
{
if
(!
(
otherDesc
instanceof
DataPropertyDescriptor
))
{
return
false
;
}
final
DataPropertyDescriptor
other
=
(
DataPropertyDescriptor
)
otherDesc
;
return
(!
has
(
CONFIGURABLE
)
||
sameValue
(
configurable
,
other
.
configurable
))
&&
(!
has
(
ENUMERABLE
)
||
sameValue
(
enumerable
,
other
.
enumerable
))
&&
(!
has
(
WRITABLE
)
||
sameValue
(
writable
,
other
.
writable
))
&&
(!
has
(
VALUE
)
||
sameValue
(
value
,
other
.
value
));
}
@Override
public
boolean
equals
(
final
Object
obj
)
{
if
(
this
==
obj
)
{
...
...
src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java
浏览文件 @
c858eb64
...
...
@@ -148,6 +148,23 @@ public final class GenericPropertyDescriptor extends ScriptObject implements Pro
return
GENERIC
;
}
@Override
public
boolean
hasAndEquals
(
final
PropertyDescriptor
other
)
{
if
(
has
(
CONFIGURABLE
)
&&
other
.
has
(
CONFIGURABLE
))
{
if
(
isConfigurable
()
!=
other
.
isConfigurable
())
{
return
false
;
}
}
if
(
has
(
ENUMERABLE
)
&&
other
.
has
(
ENUMERABLE
))
{
if
(
isEnumerable
()
!=
other
.
isEnumerable
())
{
return
false
;
}
}
return
true
;
}
@Override
public
boolean
equals
(
final
Object
obj
)
{
if
(
this
==
obj
)
{
...
...
src/jdk/nashorn/internal/runtime/PropertyDescriptor.java
浏览文件 @
c858eb64
...
...
@@ -151,5 +151,12 @@ public interface PropertyDescriptor {
* @return true if property exists in implementor
*/
public
boolean
has
(
Object
key
);
/**
* Check existence and compare attributes of descriptors.
*
* @return true if every field of this desc exists in otherDesc and has the same value.
*/
public
boolean
hasAndEquals
(
PropertyDescriptor
otherDesc
);
}
src/jdk/nashorn/internal/runtime/ScriptObject.java
浏览文件 @
c858eb64
...
...
@@ -469,7 +469,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
return
true
;
}
if
(
currentDesc
.
equals
(
new
Desc
))
{
if
(
newDesc
.
hasAndEquals
(
current
Desc
))
{
// every descriptor field of the new is same as the current
return
true
;
}
...
...
test/script/basic/JDK-8030197.js
0 → 100644
浏览文件 @
c858eb64
/*
* Copyright (c) 2014, 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.
*/
/**
* JDK-8030197: Nashorn: Object.defineProperty() can be lured to change fixed NaN property
*
* @test
* @run
*/
function
str
(
n
)
{
var
a
=
new
Uint8Array
(
new
Float64Array
([
n
]).
buffer
);
return
Array
.
apply
(
null
,
a
).
reduceRight
(
function
(
acc
,
v
){
return
acc
+
(
v
<
10
?
"
0
"
:
""
)
+
v
.
toString
(
16
);
},
""
);
}
var
o
=
Object
.
defineProperty
({},
"
NaN
"
,
{
value
:
NaN
})
var
str1
=
str
(
o
.
NaN
);
Object
.
defineProperty
(
o
,
"
NaN
"
,
{
value
:
0
/
0
})
var
str2
=
str
(
o
.
NaN
);
if
(
str1
!=
str2
)
{
fail
(
"
NaN bit pattern changed
"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录