Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
a4eb4168
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a4eb4168
编写于
1月 18, 2010
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6916890: (sctp) SctpChannel.send may cause IAE if given a heap buffer with an offset
Reviewed-by: alanb
上级
da01003f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
118 addition
and
22 deletion
+118
-22
jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
+14
-11
jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
+12
-8
jdk/test/com/sun/nio/sctp/SctpChannel/Send.java
jdk/test/com/sun/nio/sctp/SctpChannel/Send.java
+47
-3
jdk/test/com/sun/nio/sctp/SctpMultiChannel/Send.java
jdk/test/com/sun/nio/sctp/SctpMultiChannel/Send.java
+45
-0
未找到文件。
jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
浏览文件 @
a4eb4168
...
...
@@ -869,8 +869,8 @@ public class SctpChannelImpl extends SctpChannel
public
HandlerResult
handleNotification
(
AssociationChangeNotification
not
,
T
unused
)
{
if
(
not
.
event
().
equals
(
AssociationChangeNotification
.
AssocChangeEvent
.
COMM_UP
)
)
{
assert
association
==
null
;
AssociationChangeNotification
.
AssocChangeEvent
.
COMM_UP
)
&&
association
==
null
)
{
SctpAssocChange
sac
=
(
SctpAssocChange
)
not
;
association
=
new
SctpAssociationImpl
(
sac
.
assocId
(),
sac
.
maxInStreams
(),
sac
.
maxOutStreams
());
...
...
@@ -982,17 +982,17 @@ public class SctpChannelImpl extends SctpChannel
SocketAddress
target
=
messageInfo
.
address
();
boolean
unordered
=
messageInfo
.
isUnordered
();
int
ppid
=
messageInfo
.
payloadProtocolID
();
int
pos
=
src
.
position
();
int
lim
=
src
.
limit
();
assert
(
pos
<=
lim
&&
streamNumber
>=
0
);
int
rem
=
(
pos
<=
lim
?
lim
-
pos
:
0
);
if
(
src
instanceof
DirectBuffer
)
return
sendFromNativeBuffer
(
fd
,
src
,
rem
,
pos
,
target
,
streamNumber
,
return
sendFromNativeBuffer
(
fd
,
src
,
target
,
streamNumber
,
unordered
,
ppid
);
/* Substitute a native buffer */
int
pos
=
src
.
position
();
int
lim
=
src
.
limit
();
assert
(
pos
<=
lim
&&
streamNumber
>=
0
);
int
rem
=
(
pos
<=
lim
?
lim
-
pos
:
0
);
ByteBuffer
bb
=
Util
.
getTemporaryDirectBuffer
(
rem
);
try
{
bb
.
put
(
src
);
...
...
@@ -1000,7 +1000,7 @@ public class SctpChannelImpl extends SctpChannel
/* Do not update src until we see how many bytes were written */
src
.
position
(
pos
);
int
n
=
sendFromNativeBuffer
(
fd
,
bb
,
rem
,
pos
,
target
,
streamNumber
,
int
n
=
sendFromNativeBuffer
(
fd
,
bb
,
target
,
streamNumber
,
unordered
,
ppid
);
if
(
n
>
0
)
{
/* now update src */
...
...
@@ -1014,13 +1014,16 @@ public class SctpChannelImpl extends SctpChannel
private
int
sendFromNativeBuffer
(
int
fd
,
ByteBuffer
bb
,
int
rem
,
int
pos
,
SocketAddress
target
,
int
streamNumber
,
boolean
unordered
,
int
ppid
)
throws
IOException
{
int
pos
=
bb
.
position
();
int
lim
=
bb
.
limit
();
assert
(
pos
<=
lim
);
int
rem
=
(
pos
<=
lim
?
lim
-
pos
:
0
);
int
written
=
send0
(
fd
,
((
DirectBuffer
)
bb
).
address
()
+
pos
,
rem
,
target
,
-
1
/*121*/
,
streamNumber
,
unordered
,
ppid
);
if
(
written
>
0
)
...
...
jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
浏览文件 @
a4eb4168
...
...
@@ -842,16 +842,17 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
int
streamNumber
=
messageInfo
.
streamNumber
();
boolean
unordered
=
messageInfo
.
isUnordered
();
int
ppid
=
messageInfo
.
payloadProtocolID
();
int
pos
=
src
.
position
();
int
lim
=
src
.
limit
();
assert
(
pos
<=
lim
&&
streamNumber
>=
0
);
int
rem
=
(
pos
<=
lim
?
lim
-
pos
:
0
);
if
(
src
instanceof
DirectBuffer
)
return
sendFromNativeBuffer
(
fd
,
src
,
rem
,
pos
,
target
,
assocId
,
return
sendFromNativeBuffer
(
fd
,
src
,
target
,
assocId
,
streamNumber
,
unordered
,
ppid
);
/* Substitute a native buffer */
int
pos
=
src
.
position
();
int
lim
=
src
.
limit
();
assert
(
pos
<=
lim
&&
streamNumber
>=
0
);
int
rem
=
(
pos
<=
lim
?
lim
-
pos
:
0
);
ByteBuffer
bb
=
Util
.
getTemporaryDirectBuffer
(
rem
);
try
{
bb
.
put
(
src
);
...
...
@@ -859,7 +860,7 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
/* Do not update src until we see how many bytes were written */
src
.
position
(
pos
);
int
n
=
sendFromNativeBuffer
(
fd
,
bb
,
rem
,
pos
,
target
,
assocId
,
int
n
=
sendFromNativeBuffer
(
fd
,
bb
,
target
,
assocId
,
streamNumber
,
unordered
,
ppid
);
if
(
n
>
0
)
{
/* now update src */
...
...
@@ -873,14 +874,17 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
private
int
sendFromNativeBuffer
(
int
fd
,
ByteBuffer
bb
,
int
rem
,
int
pos
,
SocketAddress
target
,
int
assocId
,
int
streamNumber
,
boolean
unordered
,
int
ppid
)
throws
IOException
{
int
pos
=
bb
.
position
();
int
lim
=
bb
.
limit
();
assert
(
pos
<=
lim
);
int
rem
=
(
pos
<=
lim
?
lim
-
pos
:
0
);
int
written
=
send0
(
fd
,
((
DirectBuffer
)
bb
).
address
()
+
pos
,
rem
,
target
,
assocId
,
streamNumber
,
unordered
,
ppid
);
if
(
written
>
0
)
...
...
jdk/test/com/sun/nio/sctp/SctpChannel/Send.java
浏览文件 @
a4eb4168
...
...
@@ -112,9 +112,6 @@ public class Send {
/* Receive CommUp */
channel
.
receive
(
buffer
,
null
,
handler
);
/* save for TEST 8 */
Association
association
=
channel
.
association
();
/* TEST 2: send small message */
int
streamNumber
=
0
;
debug
(
"sending on stream number: "
+
streamNumber
);
...
...
@@ -250,6 +247,29 @@ public class Send {
pass
();
debug
(
"OK, caught "
+
e
);
}
/* TEST 9: Send from heap buffer to force implementation to
* substitute with a native buffer, then check that its position
* is updated correctly */
buffer
.
clear
();
info
=
MessageInfo
.
createOutgoing
(
null
,
0
);
buffer
.
put
(
Util
.
SMALL_MESSAGE
.
getBytes
(
"ISO-8859-1"
));
buffer
.
flip
();
final
int
offset
=
1
;
buffer
.
position
(
offset
);
remaining
=
buffer
.
remaining
();
debug
(
"sending small message: "
+
buffer
);
try
{
sent
=
channel
.
send
(
buffer
,
info
);
check
(
sent
==
remaining
,
"sent should be equal to remaining"
);
check
(
buffer
.
position
()
==
(
offset
+
sent
),
"buffers position should have been incremented by sent"
);
}
catch
(
IllegalArgumentException
iae
)
{
fail
(
iae
+
", Error updating buffers position"
);
}
}
catch
(
IOException
ioe
)
{
unexpected
(
ioe
);
}
finally
{
...
...
@@ -335,6 +355,30 @@ public class Send {
/* TEST 7 ++ */
sc2
=
ssc
.
accept
();
/* TEST 9 */
ByteBuffer
expected
=
ByteBuffer
.
allocate
(
Util
.
SMALL_BUFFER
);
expected
.
put
(
Util
.
SMALL_MESSAGE
.
getBytes
(
"ISO-8859-1"
));
expected
.
flip
();
final
int
offset
=
1
;
expected
.
position
(
offset
);
buffer
.
clear
();
do
{
info
=
sc2
.
receive
(
buffer
,
null
,
null
);
if
(
info
==
null
)
{
fail
(
"Server: unexpected null from receive"
);
return
;
}
}
while
(!
info
.
isComplete
());
buffer
.
flip
();
check
(
info
!=
null
,
"info is null"
);
check
(
info
.
streamNumber
()
==
0
,
"message not sent on the correct stream"
);
check
(
info
.
bytes
()
==
expected
.
remaining
(),
"bytes received not equal to message length"
);
check
(
info
.
bytes
()
==
buffer
.
remaining
(),
"bytes != remaining"
);
check
(
expected
.
equals
(
buffer
),
"received message not the same as sent message"
);
clientFinishedLatch
.
await
(
10L
,
TimeUnit
.
SECONDS
);
serverFinishedLatch
.
countDown
();
}
catch
(
IOException
ioe
)
{
...
...
jdk/test/com/sun/nio/sctp/SctpMultiChannel/Send.java
浏览文件 @
a4eb4168
...
...
@@ -185,6 +185,27 @@ public class Send {
/* TEST 5: getRemoteAddresses(Association) */
channel
.
getRemoteAddresses
(
assoc
);
/* TEST 6: Send from heap buffer to force implementation to
* substitute with a native buffer, then check that its position
* is updated correctly */
info
=
MessageInfo
.
createOutgoing
(
assoc
,
null
,
0
);
buffer
.
clear
();
buffer
.
put
(
Util
.
SMALL_MESSAGE
.
getBytes
(
"ISO-8859-1"
));
buffer
.
flip
();
final
int
offset
=
1
;
buffer
.
position
(
offset
);
remaining
=
buffer
.
remaining
();
try
{
sent
=
channel
.
send
(
buffer
,
info
);
check
(
sent
==
remaining
,
"sent should be equal to remaining"
);
check
(
buffer
.
position
()
==
(
offset
+
sent
),
"buffers position should have been incremented by sent"
);
}
catch
(
IllegalArgumentException
iae
)
{
fail
(
iae
+
", Error updating buffers position"
);
}
}
catch
(
IOException
ioe
)
{
unexpected
(
ioe
);
}
finally
{
...
...
@@ -284,6 +305,30 @@ public class Send {
bytes
=
serverChannel
.
send
(
buffer
,
info
);
debug
(
"Server: sent "
+
bytes
+
"bytes"
);
/* TEST 6 */
ByteBuffer
expected
=
ByteBuffer
.
allocate
(
Util
.
SMALL_BUFFER
);
expected
.
put
(
Util
.
SMALL_MESSAGE
.
getBytes
(
"ISO-8859-1"
));
expected
.
flip
();
final
int
offset
=
1
;
expected
.
position
(
offset
);
buffer
.
clear
();
do
{
info
=
serverChannel
.
receive
(
buffer
,
null
,
null
);
if
(
info
==
null
)
{
fail
(
"Server: unexpected null from receive"
);
return
;
}
}
while
(!
info
.
isComplete
());
buffer
.
flip
();
check
(
info
!=
null
,
"info is null"
);
check
(
info
.
streamNumber
()
==
0
,
"message not sent on the correct stream"
);
check
(
info
.
bytes
()
==
expected
.
remaining
(),
"bytes received not equal to message length"
);
check
(
info
.
bytes
()
==
buffer
.
remaining
(),
"bytes != remaining"
);
check
(
expected
.
equals
(
buffer
),
"received message not the same as sent message"
);
clientFinishedLatch
.
await
(
10L
,
TimeUnit
.
SECONDS
);
serverFinishedLatch
.
countDown
();
}
catch
(
IOException
ioe
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录