提交 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) ...@@ -68,6 +68,16 @@ ifeq ($(PLATFORM), solaris)
FILES_reorder += reorder-$(ARCH) FILES_reorder += reorder-$(ARCH)
endif endif
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/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk include $(BUILDDIR)/common/Library.gmk
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* Native method support for java.util.zip.Inflater * Native method support for java.util.zip.Inflater
*/ */
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
...@@ -60,12 +61,13 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap) ...@@ -60,12 +61,13 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
{ {
z_stream *strm = calloc(1, sizeof(z_stream)); z_stream *strm = calloc(1, sizeof(z_stream));
if (strm == 0) { if (strm == NULL) {
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return jlong_zero; return jlong_zero;
} else { } else {
char *msg; const char *msg;
switch (inflateInit2(strm, nowrap ? -MAX_WBITS : MAX_WBITS)) { int ret = inflateInit2(strm, nowrap ? -MAX_WBITS : MAX_WBITS);
switch (ret) {
case Z_OK: case Z_OK:
return ptr_to_jlong(strm); return ptr_to_jlong(strm);
case Z_MEM_ERROR: case Z_MEM_ERROR:
...@@ -73,7 +75,13 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap) ...@@ -73,7 +75,13 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return jlong_zero; return jlong_zero;
default: 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); free(strm);
JNU_ThrowInternalError(env, msg); JNU_ThrowInternalError(env, msg);
return jlong_zero; return jlong_zero;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册