aboutsummaryrefslogtreecommitdiffstats
path: root/community/openjdk8/icedtea-jdk-getmntent-buffer.patch
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2017-05-30 14:38:30 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2017-05-30 15:01:15 +0000
commit874cfb1fc5eaca8c800329d7e7f911d84fb20644 (patch)
treecdb586b0cbf47612b41b4b8a1b19b2070d609f08 /community/openjdk8/icedtea-jdk-getmntent-buffer.patch
parent007c4c71aa098e197d5e42ad5ea128e50a30f56d (diff)
community/openjdk8: increase buffer size for getmntent_r
Java will only use 1024 byte buffer for parsing mounts. Unlike glibc will musl return error when this is not big enough instead of truncating it. We solve it by allocating a much bigger buffer. ref #9073 We also build without precompiled headers, which does not work eith PIE.
Diffstat (limited to 'community/openjdk8/icedtea-jdk-getmntent-buffer.patch')
-rw-r--r--community/openjdk8/icedtea-jdk-getmntent-buffer.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/community/openjdk8/icedtea-jdk-getmntent-buffer.patch b/community/openjdk8/icedtea-jdk-getmntent-buffer.patch
new file mode 100644
index 00000000000..075a9d42385
--- /dev/null
+++ b/community/openjdk8/icedtea-jdk-getmntent-buffer.patch
@@ -0,0 +1,88 @@
+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