diff options
Diffstat (limited to 'recipes-core/openjdk')
-rw-r--r-- | recipes-core/openjdk/openjdk-8-release-16xbyy.inc | 1 | ||||
-rw-r--r-- | recipes-core/openjdk/patches-openjdk-8/0011-hotspot-backport-patch-to-fix-misuses-of-strncpy-str.patch | 181 |
2 files changed, 182 insertions, 0 deletions
diff --git a/recipes-core/openjdk/openjdk-8-release-16xbyy.inc b/recipes-core/openjdk/openjdk-8-release-16xbyy.inc index 36ce073..bd440c6 100644 --- a/recipes-core/openjdk/openjdk-8-release-16xbyy.inc +++ b/recipes-core/openjdk/openjdk-8-release-16xbyy.inc | |||
@@ -17,6 +17,7 @@ PATCHES_URI = "\ | |||
17 | file://0009-jdk-disable-backtrace-musl-build-fix.patch \ | 17 | file://0009-jdk-disable-backtrace-musl-build-fix.patch \ |
18 | file://0010-build-fix-build-on-as-needed-toolchains-generic.patch \ | 18 | file://0010-build-fix-build-on-as-needed-toolchains-generic.patch \ |
19 | file://hotspot_fix_gcc8x_build.patch \ | 19 | file://hotspot_fix_gcc8x_build.patch \ |
20 | file://0011-hotspot-backport-patch-to-fix-misuses-of-strncpy-str.patch \ | ||
20 | " | 21 | " |
21 | # some patches extracted from http://cr.openjdk.java.net/~rkennke/shark-build-hotspot/webrev.01/hotspot.patch | 22 | # some patches extracted from http://cr.openjdk.java.net/~rkennke/shark-build-hotspot/webrev.01/hotspot.patch |
22 | # reported via http://mail.openjdk.java.net/pipermail/build-dev/2015-January/013972.html | 23 | # reported via http://mail.openjdk.java.net/pipermail/build-dev/2015-January/013972.html |
diff --git a/recipes-core/openjdk/patches-openjdk-8/0011-hotspot-backport-patch-to-fix-misuses-of-strncpy-str.patch b/recipes-core/openjdk/patches-openjdk-8/0011-hotspot-backport-patch-to-fix-misuses-of-strncpy-str.patch new file mode 100644 index 0000000..4ab0d7a --- /dev/null +++ b/recipes-core/openjdk/patches-openjdk-8/0011-hotspot-backport-patch-to-fix-misuses-of-strncpy-str.patch | |||
@@ -0,0 +1,181 @@ | |||
1 | From cc8fb308b36d323ee8a1e3a60e4c2ac006f710ab Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik@jci.com> | ||
3 | Date: Fri, 10 Aug 2018 14:54:45 +0100 | ||
4 | Subject: [PATCH] hotspot: backport patch to fix misuses of strncpy/strncat | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | Various small fixes around strncpy and strncat | ||
10 | |||
11 | Compilation using gcc >= 8 fails because of errors regarding | ||
12 | misuse of string functions. | ||
13 | Fix them using a backport from openjdk-10 | ||
14 | |||
15 | Modelled after http://hg.openjdk.java.net/jdk-updates/jdk10u/rev/b1608535e50f | ||
16 | |||
17 | Signed-off-by: André Draszik <andre.draszik@jci.com> | ||
18 | |||
19 | --- | ||
20 | Upstream-Status: Backport [http://hg.openjdk.java.net/jdk-updates/jdk10u/rev/b1608535e50f] | ||
21 | hotspot/agent/src/os/linux/libproc_impl.c | 7 ++++++- | ||
22 | hotspot/src/share/tools/hsdis/hsdis.c | 1 + | ||
23 | hotspot/src/share/vm/compiler/compileBroker.hpp | 3 ++- | ||
24 | hotspot/src/share/vm/compiler/disassembler.cpp | 1 + | ||
25 | hotspot/src/share/vm/runtime/arguments.cpp | 13 ++++++------- | ||
26 | hotspot/src/share/vm/utilities/ostream.cpp | 14 +++++++++----- | ||
27 | hotspot/src/share/vm/utilities/vmError.cpp | 9 +-------- | ||
28 | 7 files changed, 26 insertions(+), 22 deletions(-) | ||
29 | |||
30 | diff --git a/hotspot/agent/src/os/linux/libproc_impl.c b/hotspot/agent/src/os/linux/libproc_impl.c | ||
31 | index 2ea0d0f8..ab23fb16 100644 | ||
32 | --- a/hotspot/agent/src/os/linux/libproc_impl.c | ||
33 | +++ b/hotspot/agent/src/os/linux/libproc_impl.c | ||
34 | @@ -162,7 +162,12 @@ lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd, | ||
35 | return NULL; | ||
36 | } | ||
37 | |||
38 | - strncpy(newlib->name, libname, sizeof(newlib->name)); | ||
39 | + if (strlen(libname) >= sizeof(newlib->name)) { | ||
40 | + print_debug("libname %s too long\n", libname); | ||
41 | + return NULL; | ||
42 | + } | ||
43 | + strcpy(newlib->name, libname); | ||
44 | + | ||
45 | newlib->base = base; | ||
46 | |||
47 | if (fd == -1) { | ||
48 | diff --git a/hotspot/src/share/tools/hsdis/hsdis.c b/hotspot/src/share/tools/hsdis/hsdis.c | ||
49 | index b56330e4..4e6fd9af 100644 | ||
50 | --- a/hotspot/src/share/tools/hsdis/hsdis.c | ||
51 | +++ b/hotspot/src/share/tools/hsdis/hsdis.c | ||
52 | @@ -410,6 +410,7 @@ static void parse_caller_options(struct hsdis_app_data* app_data, const char* ca | ||
53 | } | ||
54 | p = q; | ||
55 | } | ||
56 | + *iop = '\0'; | ||
57 | } | ||
58 | |||
59 | static void print_help(struct hsdis_app_data* app_data, | ||
60 | diff --git a/hotspot/src/share/vm/compiler/compileBroker.hpp b/hotspot/src/share/vm/compiler/compileBroker.hpp | ||
61 | index 7a381cd3..2aea6dd1 100644 | ||
62 | --- a/hotspot/src/share/vm/compiler/compileBroker.hpp | ||
63 | +++ b/hotspot/src/share/vm/compiler/compileBroker.hpp | ||
64 | @@ -173,7 +173,8 @@ class CompilerCounters : public CHeapObj<mtCompiler> { | ||
65 | // these methods should be called in a thread safe context | ||
66 | |||
67 | void set_current_method(const char* method) { | ||
68 | - strncpy(_current_method, method, (size_t)cmname_buffer_length); | ||
69 | + strncpy(_current_method, method, (size_t)cmname_buffer_length-1); | ||
70 | + _current_method[cmname_buffer_length-1] = '\0'; | ||
71 | if (UsePerfData) _perf_current_method->set_value(method); | ||
72 | } | ||
73 | |||
74 | diff --git a/hotspot/src/share/vm/compiler/disassembler.cpp b/hotspot/src/share/vm/compiler/disassembler.cpp | ||
75 | index 69974763..111214a9 100644 | ||
76 | --- a/hotspot/src/share/vm/compiler/disassembler.cpp | ||
77 | +++ b/hotspot/src/share/vm/compiler/disassembler.cpp | ||
78 | @@ -298,6 +298,7 @@ address decode_env::handle_event(const char* event, address arg) { | ||
79 | strlen((const char*)arg) > sizeof(buffer) - 1) { | ||
80 | // Only print this when the mach changes | ||
81 | strncpy(buffer, (const char*)arg, sizeof(buffer) - 1); | ||
82 | + buffer[sizeof(buffer) - 1] = '\0'; | ||
83 | output()->print_cr("[Disassembling for mach='%s']", arg); | ||
84 | } | ||
85 | } else if (match(event, "format bytes-per-line")) { | ||
86 | diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp | ||
87 | index cccff7a8..7589b443 100644 | ||
88 | --- a/hotspot/src/share/vm/runtime/arguments.cpp | ||
89 | +++ b/hotspot/src/share/vm/runtime/arguments.cpp | ||
90 | @@ -3430,7 +3430,7 @@ void Arguments::fix_appclasspath() { | ||
91 | } | ||
92 | |||
93 | char* copy = AllocateHeap(strlen(src) + 1, mtInternal); | ||
94 | - strncpy(copy, src, strlen(src) + 1); | ||
95 | + strcpy(copy, src); | ||
96 | |||
97 | // trim all trailing empty paths | ||
98 | for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) { | ||
99 | @@ -3804,17 +3804,16 @@ static char* get_shared_archive_path() { | ||
100 | if (end != NULL) *end = '\0'; | ||
101 | size_t jvm_path_len = strlen(jvm_path); | ||
102 | size_t file_sep_len = strlen(os::file_separator()); | ||
103 | - shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len + | ||
104 | - file_sep_len + 20, mtInternal); | ||
105 | + const size_t len = jvm_path_len + file_sep_len + 20; | ||
106 | + shared_archive_path = NEW_C_HEAP_ARRAY(char, len, mtInternal); | ||
107 | if (shared_archive_path != NULL) { | ||
108 | - strncpy(shared_archive_path, jvm_path, jvm_path_len + 1); | ||
109 | - strncat(shared_archive_path, os::file_separator(), file_sep_len); | ||
110 | - strncat(shared_archive_path, "classes.jsa", 11); | ||
111 | + jio_snprintf(shared_archive_path, len, "%s%sclasses.jsa", | ||
112 | + jvm_path, os::file_separator()); | ||
113 | } | ||
114 | } else { | ||
115 | shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(SharedArchiveFile) + 1, mtInternal); | ||
116 | if (shared_archive_path != NULL) { | ||
117 | - strncpy(shared_archive_path, SharedArchiveFile, strlen(SharedArchiveFile) + 1); | ||
118 | + strcpy(shared_archive_path, SharedArchiveFile); | ||
119 | } | ||
120 | } | ||
121 | return shared_archive_path; | ||
122 | diff --git a/hotspot/src/share/vm/utilities/ostream.cpp b/hotspot/src/share/vm/utilities/ostream.cpp | ||
123 | index 44ce683d..bc3773fe 100644 | ||
124 | --- a/hotspot/src/share/vm/utilities/ostream.cpp | ||
125 | +++ b/hotspot/src/share/vm/utilities/ostream.cpp | ||
126 | @@ -112,7 +112,7 @@ const char* outputStream::do_vsnprintf(char* buffer, size_t buflen, | ||
127 | } | ||
128 | if (add_cr) { | ||
129 | if (result != buffer) { | ||
130 | - strncpy(buffer, result, buflen); | ||
131 | + memcpy(buffer, result, result_len); | ||
132 | result = buffer; | ||
133 | } | ||
134 | buffer[result_len++] = '\n'; | ||
135 | @@ -337,15 +337,19 @@ void stringStream::write(const char* s, size_t len) { | ||
136 | assert(rm == NULL || Thread::current()->current_resource_mark() == rm, | ||
137 | "stringStream is re-allocated with a different ResourceMark"); | ||
138 | buffer = NEW_RESOURCE_ARRAY(char, end); | ||
139 | - strncpy(buffer, oldbuf, buffer_pos); | ||
140 | + if (buffer_pos > 0) { | ||
141 | + memcpy(buffer, oldbuf, buffer_pos); | ||
142 | + } | ||
143 | buffer_length = end; | ||
144 | } | ||
145 | } | ||
146 | // invariant: buffer is always null-terminated | ||
147 | guarantee(buffer_pos + write_len + 1 <= buffer_length, "stringStream oob"); | ||
148 | - buffer[buffer_pos + write_len] = 0; | ||
149 | - strncpy(buffer + buffer_pos, s, write_len); | ||
150 | - buffer_pos += write_len; | ||
151 | + if (write_len > 0) { | ||
152 | + buffer[buffer_pos + write_len] = 0; | ||
153 | + memcpy(buffer + buffer_pos, s, write_len); | ||
154 | + buffer_pos += write_len; | ||
155 | + } | ||
156 | |||
157 | // Note that the following does not depend on write_len. | ||
158 | // This means that position and count get updated | ||
159 | diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp | ||
160 | index 15f6bf48..4ab85f5d 100644 | ||
161 | --- a/hotspot/src/share/vm/utilities/vmError.cpp | ||
162 | +++ b/hotspot/src/share/vm/utilities/vmError.cpp | ||
163 | @@ -421,14 +421,7 @@ void VMError::report(outputStream* st) { | ||
164 | #else | ||
165 | const char *file = _filename; | ||
166 | #endif | ||
167 | - size_t len = strlen(file); | ||
168 | - size_t buflen = sizeof(buf); | ||
169 | - | ||
170 | - strncpy(buf, file, buflen); | ||
171 | - if (len + 10 < buflen) { | ||
172 | - sprintf(buf + len, ":%d", _lineno); | ||
173 | - } | ||
174 | - st->print(" (%s)", buf); | ||
175 | + st->print(" (%s:%d)", file, _lineno); | ||
176 | } else { | ||
177 | st->print(" (0x%x)", _id); | ||
178 | } | ||
179 | -- | ||
180 | 2.18.0 | ||
181 | |||