diff options
Diffstat (limited to 'recipes-core/openjdk/patches-openjdk-8/musl-0002-jdk-give-a-much-bigger-buffer-to-getmntent_r.patch')
-rw-r--r-- | recipes-core/openjdk/patches-openjdk-8/musl-0002-jdk-give-a-much-bigger-buffer-to-getmntent_r.patch | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/recipes-core/openjdk/patches-openjdk-8/musl-0002-jdk-give-a-much-bigger-buffer-to-getmntent_r.patch b/recipes-core/openjdk/patches-openjdk-8/musl-0002-jdk-give-a-much-bigger-buffer-to-getmntent_r.patch new file mode 100644 index 0000000..1874f87 --- /dev/null +++ b/recipes-core/openjdk/patches-openjdk-8/musl-0002-jdk-give-a-much-bigger-buffer-to-getmntent_r.patch | |||
@@ -0,0 +1,103 @@ | |||
1 | From 2ba0f3fae90f2d2c310663e4b39e90f969116241 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik at jci.com <https://lists.yoctoproject.org/listinfo/yocto>> | ||
3 | Date: Tue, 27 Feb 2018 15:59:09 +0000 | ||
4 | Subject: [PATCH 2/9] jdk: give a much bigger buffer to getmntent_r() | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | https://bugs.alpinelinux.org/issues/7093 | ||
10 | |||
11 | Upstream-Status: Inappropriate [musl specific] | ||
12 | Signed-off-by: André Draszik <andre.draszik at jci.com <https://lists.yoctoproject.org/listinfo/yocto>> | ||
13 | --- | ||
14 | .../native/sun/nio/fs/LinuxNativeDispatcher.c | 29 +++++++++++++++------- | ||
15 | 1 file changed, 20 insertions(+), 9 deletions(-) | ||
16 | |||
17 | diff --git a/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c | ||
18 | index c8500db5..d0b85d67 100644 | ||
19 | --- a/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c | ||
20 | +++ b/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c | ||
21 | @@ -33,6 +33,7 @@ | ||
22 | #include <dlfcn.h> | ||
23 | #include <errno.h> | ||
24 | #include <mntent.h> | ||
25 | +#include <limits.h> | ||
26 | |||
27 | #include "sun_nio_fs_LinuxNativeDispatcher.h" | ||
28 | |||
29 | @@ -173,8 +174,8 @@ Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this, | ||
30 | jlong value, jobject entry) | ||
31 | { | ||
32 | struct mntent ent; | ||
33 | - char buf[1024]; | ||
34 | - int buflen = sizeof(buf); | ||
35 | + char *buf = NULL; | ||
36 | + const size_t buflen = PATH_MAX * 4; | ||
37 | struct mntent* m; | ||
38 | FILE* fp = jlong_to_ptr(value); | ||
39 | jsize len; | ||
40 | @@ -183,10 +184,17 @@ Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this, | ||
41 | char* dir; | ||
42 | char* fstype; | ||
43 | char* options; | ||
44 | + jint res = -1; | ||
45 | |||
46 | - m = getmntent_r(fp, &ent, (char*)&buf, buflen); | ||
47 | - if (m == NULL) | ||
48 | + buf = malloc(buflen); | ||
49 | + if (buf == NULL) { | ||
50 | + JNU_ThrowOutOfMemoryError(env, "native heap"); | ||
51 | return -1; | ||
52 | + } | ||
53 | + m = getmntent_r(fp, &ent, buf, buflen); | ||
54 | + if (m == NULL) | ||
55 | + goto out; | ||
56 | + | ||
57 | name = m->mnt_fsname; | ||
58 | dir = m->mnt_dir; | ||
59 | fstype = m->mnt_type; | ||
60 | @@ -195,32 +203,35 @@ Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this, | ||
61 | len = strlen(name); | ||
62 | bytes = (*env)->NewByteArray(env, len); | ||
63 | if (bytes == NULL) | ||
64 | - return -1; | ||
65 | + goto out; | ||
66 | (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)name); | ||
67 | (*env)->SetObjectField(env, entry, entry_name, bytes); | ||
68 | |||
69 | len = strlen(dir); | ||
70 | bytes = (*env)->NewByteArray(env, len); | ||
71 | if (bytes == NULL) | ||
72 | - return -1; | ||
73 | + goto out; | ||
74 | (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)dir); | ||
75 | (*env)->SetObjectField(env, entry, entry_dir, bytes); | ||
76 | |||
77 | len = strlen(fstype); | ||
78 | bytes = (*env)->NewByteArray(env, len); | ||
79 | if (bytes == NULL) | ||
80 | - return -1; | ||
81 | + goto out; | ||
82 | (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)fstype); | ||
83 | (*env)->SetObjectField(env, entry, entry_fstype, bytes); | ||
84 | |||
85 | len = strlen(options); | ||
86 | bytes = (*env)->NewByteArray(env, len); | ||
87 | if (bytes == NULL) | ||
88 | - return -1; | ||
89 | + goto out; | ||
90 | (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options); | ||
91 | (*env)->SetObjectField(env, entry, entry_options, bytes); | ||
92 | |||
93 | - return 0; | ||
94 | + res = 0; | ||
95 | +out: | ||
96 | + free(buf); | ||
97 | + return res; | ||
98 | } | ||
99 | |||
100 | JNIEXPORT void JNICALL | ||
101 | -- | ||
102 | 2.16.2 | ||
103 | |||