--- a/hotspot/src/share/vm/prims/jvm.cpp Mon Nov 03 11:34:13 2014 -0800
+++ b/hotspot/src/share/vm/prims/jvm.cpp Wed Oct 29 10:13:24 2014 +0100
@@ -2583,7 +2583,14 @@
int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
// see bug 4399518, 4417214
if ((intptr_t)count <= 0) return -1;
- return vsnprintf(str, count, fmt, args);
+
+ int result = vsnprintf(str, count, fmt, args);
+ if ((result > 0 && (size_t)result >= count) || result == -1) {
+ str[count - 1] = '\0';
+ result = -1;
+ }
+
+ return result;
}
ATTRIBUTE_PRINTF(3, 0)