Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
02c64796
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看板
提交
02c64796
编写于
8月 11, 2016
作者:
I
igerasim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8163518: Integer overflow in StringBufferInputStream.read() and CharArrayReader.read/skip()
Reviewed-by: rriggs, shade
上级
4286b4eb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
162 addition
and
6 deletion
+162
-6
src/share/classes/java/io/CharArrayReader.java
src/share/classes/java/io/CharArrayReader.java
+8
-4
src/share/classes/java/io/StringBufferInputStream.java
src/share/classes/java/io/StringBufferInputStream.java
+4
-2
test/java/io/CharArrayReader/OverflowInRead.java
test/java/io/CharArrayReader/OverflowInRead.java
+50
-0
test/java/io/CharArrayReader/OverflowInSkip.java
test/java/io/CharArrayReader/OverflowInSkip.java
+51
-0
test/java/io/StringBufferInputStream/OverflowInRead.java
test/java/io/StringBufferInputStream/OverflowInRead.java
+49
-0
未找到文件。
src/share/classes/java/io/CharArrayReader.java
浏览文件 @
02c64796
...
@@ -130,8 +130,10 @@ public class CharArrayReader extends Reader {
...
@@ -130,8 +130,10 @@ public class CharArrayReader extends Reader {
if
(
pos
>=
count
)
{
if
(
pos
>=
count
)
{
return
-
1
;
return
-
1
;
}
}
if
(
pos
+
len
>
count
)
{
len
=
count
-
pos
;
int
avail
=
count
-
pos
;
if
(
len
>
avail
)
{
len
=
avail
;
}
}
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
return
0
;
return
0
;
...
@@ -157,8 +159,10 @@ public class CharArrayReader extends Reader {
...
@@ -157,8 +159,10 @@ public class CharArrayReader extends Reader {
public
long
skip
(
long
n
)
throws
IOException
{
public
long
skip
(
long
n
)
throws
IOException
{
synchronized
(
lock
)
{
synchronized
(
lock
)
{
ensureOpen
();
ensureOpen
();
if
(
pos
+
n
>
count
)
{
n
=
count
-
pos
;
long
avail
=
count
-
pos
;
if
(
n
>
avail
)
{
n
=
avail
;
}
}
if
(
n
<
0
)
{
if
(
n
<
0
)
{
return
0
;
return
0
;
...
...
src/share/classes/java/io/StringBufferInputStream.java
浏览文件 @
02c64796
...
@@ -118,8 +118,10 @@ class StringBufferInputStream extends InputStream {
...
@@ -118,8 +118,10 @@ class StringBufferInputStream extends InputStream {
if
(
pos
>=
count
)
{
if
(
pos
>=
count
)
{
return
-
1
;
return
-
1
;
}
}
if
(
pos
+
len
>
count
)
{
len
=
count
-
pos
;
int
avail
=
count
-
pos
;
if
(
len
>
avail
)
{
len
=
avail
;
}
}
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
return
0
;
return
0
;
...
...
test/java/io/CharArrayReader/OverflowInRead.java
0 → 100644
浏览文件 @
02c64796
/*
* 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 8163518
* @summary Integer overflow when reading in large buffer
* @requires (os.simpleArch == "x64" & os.maxMemory > 8g)
* @run main/othervm -Xmx8g OverflowInRead
*/
import
java.io.CharArrayReader
;
public
class
OverflowInRead
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
char
[]
a
=
"_123456789_123456789_123456789_123456789"
.
toCharArray
();
// a.length > 33
try
(
CharArrayReader
car
=
new
CharArrayReader
(
a
))
{
int
len1
=
33
;
char
[]
buf1
=
new
char
[
len1
];
if
(
car
.
read
(
buf1
,
0
,
len1
)
!=
len1
)
throw
new
Exception
(
"Expected to read "
+
len1
+
" chars"
);
int
len2
=
Integer
.
MAX_VALUE
-
32
;
char
[]
buf2
=
new
char
[
len2
];
int
expLen2
=
a
.
length
-
len1
;
if
(
car
.
read
(
buf2
,
0
,
len2
)
!=
expLen2
)
throw
new
Exception
(
"Expected to read "
+
expLen2
+
" chars"
);
}
}
}
test/java/io/CharArrayReader/OverflowInSkip.java
0 → 100644
浏览文件 @
02c64796
/*
* 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 8163518
* @summary Integer overflow when skipping a lot
*/
import
java.io.CharArrayReader
;
public
class
OverflowInSkip
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
char
[]
a
=
"_123456789_123456789_123456789_123456789"
.
toCharArray
();
// a.length > 33
try
(
CharArrayReader
car
=
new
CharArrayReader
(
a
))
{
long
small
=
33
;
long
big
=
Long
.
MAX_VALUE
;
long
smallSkip
=
car
.
skip
(
small
);
if
(
smallSkip
!=
small
)
throw
new
Exception
(
"Expected to skip "
+
small
+
" chars, but skipped "
+
smallSkip
);
long
expSkip
=
a
.
length
-
small
;
long
bigSkip
=
car
.
skip
(
big
);
if
(
bigSkip
!=
expSkip
)
throw
new
Exception
(
"Expected to skip "
+
expSkip
+
" chars, but skipped "
+
bigSkip
);
}
}
}
test/java/io/StringBufferInputStream/OverflowInRead.java
0 → 100644
浏览文件 @
02c64796
/*
* 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 8163518
* @summary Integer overflow when reading in large buffer
* @requires (os.simpleArch == "x64" & os.maxMemory > 4g)
* @run main/othervm -Xmx4g OverflowInRead
*/
import
java.io.StringBufferInputStream
;
public
class
OverflowInRead
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
s
=
"_123456789_123456789_123456789_123456789"
;
// s.length() > 33
try
(
StringBufferInputStream
sbis
=
new
StringBufferInputStream
(
s
))
{
int
len1
=
33
;
byte
[]
buf1
=
new
byte
[
len1
];
if
(
sbis
.
read
(
buf1
,
0
,
len1
)
!=
len1
)
throw
new
Exception
(
"Expected to read "
+
len1
+
" bytes"
);
int
len2
=
Integer
.
MAX_VALUE
-
32
;
byte
[]
buf2
=
new
byte
[
len2
];
int
expLen2
=
s
.
length
()
-
len1
;
if
(
sbis
.
read
(
buf2
,
0
,
len2
)
!=
expLen2
)
throw
new
Exception
(
"Expected to read "
+
expLen2
+
" bytes"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录