Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
b0ad6efd
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,发现更多精彩内容 >>
提交
b0ad6efd
编写于
6月 11, 2019
作者:
L
lancea
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8225189: Multiple JNI calls within critical region in ZIP Library
Reviewed-by: alanb
上级
de5d5b3d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
85 addition
and
53 deletion
+85
-53
src/java.base/share/native/libzip/Deflater.c
src/java.base/share/native/libzip/Deflater.c
+48
-29
src/java.base/share/native/libzip/Inflater.c
src/java.base/share/native/libzip/Inflater.c
+37
-24
未找到文件。
src/java.base/share/native/libzip/Deflater.c
浏览文件 @
b0ad6efd
/*
* Copyright (c) 1997, 201
8
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
9
, 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
...
...
@@ -76,9 +76,8 @@ Java_java_util_zip_Deflater_init(JNIEnv *env, jclass cls, jint level,
}
}
static
void
doSetDictionary
(
JNIEnv
*
env
,
jlong
addr
,
jbyte
*
buf
,
jint
len
)
static
void
checkSetDictionaryResult
(
JNIEnv
*
env
,
jlong
addr
,
jint
res
)
{
int
res
=
deflateSetDictionary
(
jlong_to_ptr
(
addr
),
(
Bytef
*
)
buf
,
len
);
switch
(
res
)
{
case
Z_OK
:
break
;
...
...
@@ -95,30 +94,33 @@ JNIEXPORT void JNICALL
Java_java_util_zip_Deflater_setDictionary
(
JNIEnv
*
env
,
jclass
cls
,
jlong
addr
,
jbyteArray
b
,
jint
off
,
jint
len
)
{
jbyte
*
buf
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
b
,
0
);
int
res
;
Bytef
*
buf
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
b
,
0
);
if
(
buf
==
NULL
)
/* out of memory */
return
;
doSetDictionary
(
env
,
addr
,
buf
+
of
f
,
len
);
res
=
deflateSetDictionary
(
jlong_to_ptr
(
addr
),
bu
f
,
len
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
b
,
buf
,
0
);
checkSetDictionaryResult
(
env
,
addr
,
res
);
}
JNIEXPORT
void
JNICALL
Java_java_util_zip_Deflater_setDictionaryBuffer
(
JNIEnv
*
env
,
jclass
cls
,
jlong
addr
,
jlong
bufferAddr
,
jint
len
)
{
jbyte
*
buf
=
jlong_to_ptr
(
bufferAddr
);
doSetDictionary
(
env
,
addr
,
buf
,
len
);
int
res
;
Bytef
*
buf
=
jlong_to_ptr
(
bufferAddr
);
res
=
deflateSetDictionary
(
jlong_to_ptr
(
addr
),
buf
,
len
);
checkSetDictionaryResult
(
env
,
addr
,
res
);
}
static
j
long
doDeflate
(
JNIEnv
*
env
,
jobject
this
,
jlong
addr
,
static
j
int
doDeflate
(
JNIEnv
*
env
,
jlong
addr
,
jbyte
*
input
,
jint
inputLen
,
jbyte
*
output
,
jint
outputLen
,
jint
flush
,
jint
params
)
{
z_stream
*
strm
=
jlong_to_ptr
(
addr
);
jint
inputUsed
=
0
,
outputUsed
=
0
;
int
finished
=
0
;
int
setParams
=
params
&
1
;
int
res
;
strm
->
next_in
=
(
Bytef
*
)
input
;
strm
->
next_out
=
(
Bytef
*
)
output
;
...
...
@@ -128,7 +130,24 @@ static jlong doDeflate(JNIEnv *env, jobject this, jlong addr,
if
(
setParams
)
{
int
strategy
=
(
params
>>
1
)
&
3
;
int
level
=
params
>>
3
;
int
res
=
deflateParams
(
strm
,
level
,
strategy
);
res
=
deflateParams
(
strm
,
level
,
strategy
);
}
else
{
res
=
deflate
(
strm
,
flush
);
}
return
res
;
}
static
jlong
checkDeflateStatus
(
JNIEnv
*
env
,
jlong
addr
,
jint
inputLen
,
jint
outputLen
,
jint
params
,
int
res
)
{
z_stream
*
strm
=
jlong_to_ptr
(
addr
);
jint
inputUsed
=
0
,
outputUsed
=
0
;
int
finished
=
0
;
int
setParams
=
params
&
1
;
if
(
setParams
)
{
switch
(
res
)
{
case
Z_OK
:
setParams
=
0
;
...
...
@@ -142,7 +161,6 @@ static jlong doDeflate(JNIEnv *env, jobject this, jlong addr,
return
0
;
}
}
else
{
int
res
=
deflate
(
strm
,
flush
);
switch
(
res
)
{
case
Z_STREAM_END
:
finished
=
1
;
...
...
@@ -169,6 +187,8 @@ Java_java_util_zip_Deflater_deflateBytesBytes(JNIEnv *env, jobject this, jlong a
jbyte
*
input
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
inputArray
,
0
);
jbyte
*
output
;
jlong
retVal
;
jint
res
;
if
(
input
==
NULL
)
{
if
(
inputLen
!=
0
&&
(
*
env
)
->
ExceptionOccurred
(
env
)
==
NULL
)
JNU_ThrowOutOfMemoryError
(
env
,
0
);
...
...
@@ -182,14 +202,13 @@ Java_java_util_zip_Deflater_deflateBytesBytes(JNIEnv *env, jobject this, jlong a
return
0L
;
}
retVal
=
doDeflate
(
env
,
this
,
addr
,
input
+
inputOff
,
inputLen
,
output
+
outputOff
,
outputLen
,
flush
,
params
);
res
=
doDeflate
(
env
,
addr
,
input
+
inputOff
,
inputLen
,
output
+
outputOff
,
outputLen
,
flush
,
params
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
outputArray
,
output
,
0
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
inputArray
,
input
,
0
);
retVal
=
checkDeflateStatus
(
env
,
addr
,
inputLen
,
outputLen
,
params
,
res
);
return
retVal
;
}
...
...
@@ -203,6 +222,7 @@ Java_java_util_zip_Deflater_deflateBytesBuffer(JNIEnv *env, jobject this, jlong
jbyte
*
input
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
inputArray
,
0
);
jbyte
*
output
;
jlong
retVal
;
jint
res
;
if
(
input
==
NULL
)
{
if
(
inputLen
!=
0
&&
(
*
env
)
->
ExceptionOccurred
(
env
)
==
NULL
)
JNU_ThrowOutOfMemoryError
(
env
,
0
);
...
...
@@ -210,13 +230,12 @@ Java_java_util_zip_Deflater_deflateBytesBuffer(JNIEnv *env, jobject this, jlong
}
output
=
jlong_to_ptr
(
outputBuffer
);
retVal
=
doDeflate
(
env
,
this
,
addr
,
input
+
inputOff
,
inputLen
,
output
,
outputLen
,
flush
,
params
);
res
=
doDeflate
(
env
,
addr
,
input
+
inputOff
,
inputLen
,
output
,
outputLen
,
flush
,
params
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
inputArray
,
input
,
0
);
retVal
=
checkDeflateStatus
(
env
,
addr
,
inputLen
,
outputLen
,
params
,
res
);
return
retVal
;
}
...
...
@@ -229,19 +248,18 @@ Java_java_util_zip_Deflater_deflateBufferBytes(JNIEnv *env, jobject this, jlong
jbyte
*
input
=
jlong_to_ptr
(
inputBuffer
);
jbyte
*
output
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
outputArray
,
0
);
jlong
retVal
;
jint
res
;
if
(
output
==
NULL
)
{
if
(
outputLen
!=
0
&&
(
*
env
)
->
ExceptionOccurred
(
env
)
==
NULL
)
JNU_ThrowOutOfMemoryError
(
env
,
0
);
return
0L
;
}
retVal
=
doDeflate
(
env
,
this
,
addr
,
input
,
inputLen
,
output
+
outputOff
,
outputLen
,
flush
,
params
);
res
=
doDeflate
(
env
,
addr
,
input
,
inputLen
,
output
+
outputOff
,
outputLen
,
flush
,
params
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
outputArray
,
input
,
0
);
retVal
=
checkDeflateStatus
(
env
,
addr
,
inputLen
,
outputLen
,
params
,
res
);
return
retVal
;
}
...
...
@@ -253,11 +271,12 @@ Java_java_util_zip_Deflater_deflateBufferBuffer(JNIEnv *env, jobject this, jlong
{
jbyte
*
input
=
jlong_to_ptr
(
inputBuffer
);
jbyte
*
output
=
jlong_to_ptr
(
outputBuffer
);
jlong
retVal
;
jint
res
;
return
doDeflate
(
env
,
this
,
addr
,
input
,
inputLen
,
output
,
outputLen
,
flush
,
params
);
res
=
doDeflate
(
env
,
addr
,
input
,
inputLen
,
output
,
outputLen
,
flush
,
params
);
retVal
=
checkDeflateStatus
(
env
,
addr
,
inputLen
,
outputLen
,
params
,
res
);
return
retVal
;
}
JNIEXPORT
jint
JNICALL
...
...
src/java.base/share/native/libzip/Inflater.c
浏览文件 @
b0ad6efd
/*
* Copyright (c) 1997, 201
8
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
9
, 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
...
...
@@ -87,9 +87,8 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
}
}
static
void
doSetDictionary
(
JNIEnv
*
env
,
jlong
addr
,
jbyte
*
buf
,
jint
len
)
static
void
checkSetDictionaryResult
(
JNIEnv
*
env
,
jlong
addr
,
int
res
)
{
int
res
=
inflateSetDictionary
(
jlong_to_ptr
(
addr
),
(
Bytef
*
)
buf
,
len
);
switch
(
res
)
{
case
Z_OK
:
break
;
...
...
@@ -107,30 +106,31 @@ JNIEXPORT void JNICALL
Java_java_util_zip_Inflater_setDictionary
(
JNIEnv
*
env
,
jclass
cls
,
jlong
addr
,
jbyteArray
b
,
jint
off
,
jint
len
)
{
jbyte
*
buf
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
b
,
0
);
jint
res
;
Bytef
*
buf
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
b
,
0
);
if
(
buf
==
NULL
)
/* out of memory */
return
;
doSetDictionary
(
env
,
addr
,
buf
+
off
,
len
);
res
=
inflateSetDictionary
(
jlong_to_ptr
(
addr
)
,
buf
+
off
,
len
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
b
,
buf
,
0
);
checkSetDictionaryResult
(
env
,
addr
,
res
);
}
JNIEXPORT
void
JNICALL
Java_java_util_zip_Inflater_setDictionaryBuffer
(
JNIEnv
*
env
,
jclass
cls
,
jlong
addr
,
jlong
bufferAddr
,
jint
len
)
{
jbyte
*
buf
=
jlong_to_ptr
(
bufferAddr
);
doSetDictionary
(
env
,
addr
,
buf
,
len
);
jint
res
;
Bytef
*
buf
=
jlong_to_ptr
(
bufferAddr
);
res
=
inflateSetDictionary
(
jlong_to_ptr
(
addr
),
buf
,
len
);
checkSetDictionaryResult
(
env
,
addr
,
res
);
}
static
j
long
doInflate
(
JNIEnv
*
env
,
jobject
this
,
jlong
addr
,
static
j
int
doInflate
(
jlong
addr
,
jbyte
*
input
,
jint
inputLen
,
jbyte
*
output
,
jint
outputLen
)
{
jint
ret
;
z_stream
*
strm
=
jlong_to_ptr
(
addr
);
jint
inputUsed
=
0
,
outputUsed
=
0
;
int
finished
=
0
;
int
needDict
=
0
;
int
ret
;
strm
->
next_in
=
(
Bytef
*
)
input
;
strm
->
next_out
=
(
Bytef
*
)
output
;
...
...
@@ -138,6 +138,16 @@ static jlong doInflate(JNIEnv *env, jobject this, jlong addr,
strm
->
avail_out
=
outputLen
;
ret
=
inflate
(
strm
,
Z_PARTIAL_FLUSH
);
return
ret
;
}
static
jlong
checkInflateStatus
(
JNIEnv
*
env
,
jobject
this
,
jlong
addr
,
jint
inputLen
,
jint
outputLen
,
jint
ret
)
{
z_stream
*
strm
=
jlong_to_ptr
(
addr
);
jint
inputUsed
=
0
,
outputUsed
=
0
;
int
finished
=
0
;
int
needDict
=
0
;
switch
(
ret
)
{
case
Z_STREAM_END
:
...
...
@@ -180,6 +190,7 @@ Java_java_util_zip_Inflater_inflateBytesBytes(JNIEnv *env, jobject this, jlong a
{
jbyte
*
input
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
inputArray
,
0
);
jbyte
*
output
;
jint
ret
;
jlong
retVal
;
if
(
input
==
NULL
)
{
...
...
@@ -195,13 +206,13 @@ Java_java_util_zip_Inflater_inflateBytesBytes(JNIEnv *env, jobject this, jlong a
return
0L
;
}
retVal
=
doInflate
(
env
,
this
,
addr
,
input
+
inputOff
,
inputLen
,
output
+
outputOff
,
outputLen
);
ret
=
doInflate
(
addr
,
input
+
inputOff
,
inputLen
,
output
+
outputOff
,
outputLen
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
outputArray
,
output
,
0
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
inputArray
,
input
,
0
);
retVal
=
checkInflateStatus
(
env
,
this
,
addr
,
inputLen
,
outputLen
,
ret
);
return
retVal
;
}
...
...
@@ -212,6 +223,7 @@ Java_java_util_zip_Inflater_inflateBytesBuffer(JNIEnv *env, jobject this, jlong
{
jbyte
*
input
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
inputArray
,
0
);
jbyte
*
output
;
jint
ret
;
jlong
retVal
;
if
(
input
==
NULL
)
{
...
...
@@ -221,11 +233,10 @@ Java_java_util_zip_Inflater_inflateBytesBuffer(JNIEnv *env, jobject this, jlong
}
output
=
jlong_to_ptr
(
outputBuffer
);
retVal
=
doInflate
(
env
,
this
,
addr
,
input
+
inputOff
,
inputLen
,
output
,
outputLen
);
ret
=
doInflate
(
addr
,
input
+
inputOff
,
inputLen
,
output
,
outputLen
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
inputArray
,
input
,
0
);
retVal
=
checkInflateStatus
(
env
,
this
,
addr
,
inputLen
,
outputLen
,
ret
);
return
retVal
;
}
...
...
@@ -237,6 +248,7 @@ Java_java_util_zip_Inflater_inflateBufferBytes(JNIEnv *env, jobject this, jlong
{
jbyte
*
input
=
jlong_to_ptr
(
inputBuffer
);
jbyte
*
output
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
outputArray
,
0
);
jint
ret
;
jlong
retVal
;
if
(
output
==
NULL
)
{
...
...
@@ -245,11 +257,10 @@ Java_java_util_zip_Inflater_inflateBufferBytes(JNIEnv *env, jobject this, jlong
return
0L
;
}
retVal
=
doInflate
(
env
,
this
,
addr
,
input
,
inputLen
,
output
+
outputOff
,
outputLen
);
ret
=
doInflate
(
addr
,
input
,
inputLen
,
output
+
outputOff
,
outputLen
);
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
outputArray
,
output
,
0
);
retVal
=
checkInflateStatus
(
env
,
this
,
addr
,
inputLen
,
outputLen
,
ret
);
return
retVal
;
}
...
...
@@ -261,10 +272,12 @@ Java_java_util_zip_Inflater_inflateBufferBuffer(JNIEnv *env, jobject this, jlong
{
jbyte
*
input
=
jlong_to_ptr
(
inputBuffer
);
jbyte
*
output
=
jlong_to_ptr
(
outputBuffer
);
jint
ret
;
jlong
retVal
;
ret
urn
doInflate
(
env
,
this
,
addr
,
input
,
inputLen
,
output
,
outputLen
)
;
ret
=
doInflate
(
addr
,
input
,
inputLen
,
output
,
outputLen
);
retVal
=
checkInflateStatus
(
env
,
this
,
addr
,
inputLen
,
outputLen
,
ret
);
return
retVal
;
}
JNIEXPORT
jint
JNICALL
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录