void-packages/srcpkgs/openjdk8/patches/102_jdk-getmntent-buffer.patch
q66 6783ab9f47 openjdk: update to 8u232b09, rename to openjdk8, native bootstrap
This updates OpenJDK 8 to a newer version and brings a bunch of
changes.

Newly, it is bootstrapped with openjdk7-bootstrap, so it does not
need to download binaries. It can also cross-compile and is patched
for musl and other platforms.

We're newly using the aarch64 port repo in order to get aarch64
JIT. For non-aarch64 platforms, the codebase is the same.

The symlink for /usr/lib/jvm/openjdk is also now gone and we're
using a unified java-VERSION-VENDOR naming.

Also general template cleanup.

[ci skip]
2019-11-24 16:33:30 -05:00

88 lines
2.6 KiB
Diff

Give a much bigger buffer to getmntent_r.
https://bugs.alpinelinux.org/issues/7093
diff --git a/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c b/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
index c8500db..d0b85d6 100644
--- openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
+++ openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
@@ -33,6 +33,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <mntent.h>
+#include <limits.h>
#include "sun_nio_fs_LinuxNativeDispatcher.h"
@@ -173,8 +174,8 @@ Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this,
jlong value, jobject entry)
{
struct mntent ent;
- char buf[1024];
- int buflen = sizeof(buf);
+ char *buf = NULL;
+ const size_t buflen = PATH_MAX * 4;
struct mntent* m;
FILE* fp = jlong_to_ptr(value);
jsize len;
@@ -183,10 +184,17 @@ Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this,
char* dir;
char* fstype;
char* options;
+ jint res = -1;
- m = getmntent_r(fp, &ent, (char*)&buf, buflen);
- if (m == NULL)
+ buf = malloc(buflen);
+ if (buf == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "native heap");
return -1;
+ }
+ m = getmntent_r(fp, &ent, buf, buflen);
+ if (m == NULL)
+ goto out;
+
name = m->mnt_fsname;
dir = m->mnt_dir;
fstype = m->mnt_type;
@@ -195,32 +203,35 @@ Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this,
len = strlen(name);
bytes = (*env)->NewByteArray(env, len);
if (bytes == NULL)
- return -1;
+ goto out;
(*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)name);
(*env)->SetObjectField(env, entry, entry_name, bytes);
len = strlen(dir);
bytes = (*env)->NewByteArray(env, len);
if (bytes == NULL)
- return -1;
+ goto out;
(*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)dir);
(*env)->SetObjectField(env, entry, entry_dir, bytes);
len = strlen(fstype);
bytes = (*env)->NewByteArray(env, len);
if (bytes == NULL)
- return -1;
+ goto out;
(*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)fstype);
(*env)->SetObjectField(env, entry, entry_fstype, bytes);
len = strlen(options);
bytes = (*env)->NewByteArray(env, len);
if (bytes == NULL)
- return -1;
+ goto out;
(*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options);
(*env)->SetObjectField(env, entry, entry_options, bytes);
- return 0;
+ res = 0;
+out:
+ free(buf);
+ return res;
}
JNIEXPORT void JNICALL