Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4ef15b70
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ef15b70
编写于
4月 20, 2012
作者:
Z
zhouyx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7159982: ZipFile uses static for error message when malformed zip file encountered
Reviewed-by: alanb, dholmes
上级
a3737285
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
12 deletion
+20
-12
src/share/native/java/util/zip/ZipFile.c
src/share/native/java/util/zip/ZipFile.c
+1
-0
src/share/native/java/util/zip/zip_util.c
src/share/native/java/util/zip/zip_util.c
+19
-12
未找到文件。
src/share/native/java/util/zip/ZipFile.c
浏览文件 @
4ef15b70
...
...
@@ -117,6 +117,7 @@ Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name,
result
=
ptr_to_jlong
(
zip
);
}
else
if
(
msg
!=
0
)
{
ThrowZipException
(
env
,
msg
);
free
(
msg
);
}
else
if
(
errno
==
ENOMEM
)
{
JNU_ThrowOutOfMemoryError
(
env
,
0
);
}
else
{
...
...
src/share/native/java/util/zip/zip_util.c
浏览文件 @
4ef15b70
...
...
@@ -726,7 +726,7 @@ readCEN(jzfile *zip, jint knownTotal)
* Opens a zip file with the specified mode. Returns the jzfile object
* or NULL if an error occurred. If a zip error occurred then *pmsg will
* be set to the error message text if pmsg != 0. Otherwise, *pmsg will be
* set to NULL.
* set to NULL.
Caller is responsible to free the error message.
*/
jzfile
*
ZIP_Open_Generic
(
const
char
*
name
,
char
**
pmsg
,
int
mode
,
jlong
lastModified
)
...
...
@@ -751,12 +751,12 @@ ZIP_Open_Generic(const char *name, char **pmsg, int mode, jlong lastModified)
* Returns the jzfile corresponding to the given file name from the cache of
* zip files, or NULL if the file is not in the cache. If the name is longer
* than PATH_MAX or a zip error occurred then *pmsg will be set to the error
* message text if pmsg != 0. Otherwise, *pmsg will be set to NULL.
* message text if pmsg != 0. Otherwise, *pmsg will be set to NULL. Caller
* is responsible to free the error message.
*/
jzfile
*
ZIP_Get_From_Cache
(
const
char
*
name
,
char
**
pmsg
,
jlong
lastModified
)
{
static
char
errbuf
[
256
];
char
buf
[
PATH_MAX
];
jzfile
*
zip
;
...
...
@@ -771,7 +771,7 @@ ZIP_Get_From_Cache(const char *name, char **pmsg, jlong lastModified)
if
(
strlen
(
name
)
>=
PATH_MAX
)
{
if
(
pmsg
)
{
*
pmsg
=
"zip file name too long"
;
*
pmsg
=
strdup
(
"zip file name too long"
)
;
}
return
NULL
;
}
...
...
@@ -796,7 +796,8 @@ ZIP_Get_From_Cache(const char *name, char **pmsg, jlong lastModified)
* Reads data from the given file descriptor to create a jzfile, puts the
* jzfile in a cache, and returns that jzfile. Returns NULL in case of error.
* If a zip error occurs, then *pmsg will be set to the error message text if
* pmsg != 0. Otherwise, *pmsg will be set to NULL.
* pmsg != 0. Otherwise, *pmsg will be set to NULL. Caller is responsible to
* free the error message.
*/
jzfile
*
...
...
@@ -809,7 +810,7 @@ jzfile *
ZIP_Put_In_Cache0
(
const
char
*
name
,
ZFILE
zfd
,
char
**
pmsg
,
jlong
lastModified
,
jboolean
usemmap
)
{
static
char
errbuf
[
256
];
char
errbuf
[
256
];
jlong
len
;
jzfile
*
zip
;
...
...
@@ -825,7 +826,7 @@ ZIP_Put_In_Cache0(const char *name, ZFILE zfd, char **pmsg, jlong lastModified,
if
(
zfd
==
-
1
)
{
if
(
pmsg
&&
JVM_GetLastErrorString
(
errbuf
,
sizeof
(
errbuf
))
>
0
)
*
pmsg
=
errbuf
;
*
pmsg
=
strdup
(
errbuf
)
;
freeZip
(
zip
);
return
NULL
;
}
...
...
@@ -834,11 +835,11 @@ ZIP_Put_In_Cache0(const char *name, ZFILE zfd, char **pmsg, jlong lastModified,
if
(
len
<=
0
)
{
if
(
len
==
0
)
{
/* zip file is empty */
if
(
pmsg
)
{
*
pmsg
=
"zip file is empty"
;
*
pmsg
=
strdup
(
"zip file is empty"
)
;
}
}
else
{
/* error */
if
(
pmsg
&&
JVM_GetLastErrorString
(
errbuf
,
sizeof
(
errbuf
))
>
0
)
*
pmsg
=
errbuf
;
*
pmsg
=
strdup
(
errbuf
)
;
}
ZFILE_Close
(
zfd
);
freeZip
(
zip
);
...
...
@@ -850,7 +851,8 @@ ZIP_Put_In_Cache0(const char *name, ZFILE zfd, char **pmsg, jlong lastModified,
/* An error occurred while trying to read the zip file */
if
(
pmsg
!=
0
)
{
/* Set the zip error message */
*
pmsg
=
zip
->
msg
;
if
(
zip
->
msg
!=
NULL
)
*
pmsg
=
strdup
(
zip
->
msg
);
}
freeZip
(
zip
);
return
NULL
;
...
...
@@ -867,12 +869,17 @@ ZIP_Put_In_Cache0(const char *name, ZFILE zfd, char **pmsg, jlong lastModified,
* Opens a zip file for reading. Returns the jzfile object or NULL
* if an error occurred. If a zip error occurred then *msg will be
* set to the error message text if msg != 0. Otherwise, *msg will be
* set to NULL.
* set to NULL.
Caller doesn't need to free the error message.
*/
jzfile
*
JNICALL
ZIP_Open
(
const
char
*
name
,
char
**
pmsg
)
{
return
ZIP_Open_Generic
(
name
,
pmsg
,
O_RDONLY
,
0
);
jzfile
*
file
=
ZIP_Open_Generic
(
name
,
pmsg
,
O_RDONLY
,
0
);
if
(
file
==
NULL
&&
pmsg
!=
NULL
&&
*
pmsg
!=
NULL
)
{
free
(
*
pmsg
);
*
pmsg
=
"Zip file open error"
;
}
return
file
;
}
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录