提交 03cb096d 编写于 作者: M martin

8008759: Do not let internal JDK zlib symbols leak out of fastdebug libzip.so

Summary: Define FILES_m to force use of linker script
Reviewed-by: sherman, alanb, ohair
上级 0cd9b409
......@@ -68,6 +68,16 @@ ifeq ($(PLATFORM), solaris)
FILES_reorder += reorder-$(ARCH)
endif
endif
#
# Use mapfile unconditionally (even with fastdebug).
# JDK's internal zlib is incompatible with stock zlib, because the
# size of struct z_stream has been changed, so internal zlib
# implementation must not be allowed to leak outside of libzip.so,
# else you get hard to debug failures with fastdebug jdk when user
# native code includes stock zlib.
#
FILES_m = mapfile-vers
include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk
......
......@@ -27,6 +27,7 @@
* Native method support for java.util.zip.Inflater
*/
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
......@@ -60,12 +61,13 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
{
z_stream *strm = calloc(1, sizeof(z_stream));
if (strm == 0) {
if (strm == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return jlong_zero;
} else {
char *msg;
switch (inflateInit2(strm, nowrap ? -MAX_WBITS : MAX_WBITS)) {
const char *msg;
int ret = inflateInit2(strm, nowrap ? -MAX_WBITS : MAX_WBITS);
switch (ret) {
case Z_OK:
return ptr_to_jlong(strm);
case Z_MEM_ERROR:
......@@ -73,7 +75,13 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
JNU_ThrowOutOfMemoryError(env, 0);
return jlong_zero;
default:
msg = strm->msg;
msg = ((strm->msg != NULL) ? strm->msg :
(ret == Z_VERSION_ERROR) ?
"zlib returned Z_VERSION_ERROR: "
"compile time and runtime zlib implementations differ" :
(ret == Z_STREAM_ERROR) ?
"inflateInit2 returned Z_STREAM_ERROR" :
"unknown error initializing zlib library");
free(strm);
JNU_ThrowInternalError(env, msg);
return jlong_zero;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册