hotspot/src/share/vm/utilities/xmlstream.cpp
changeset 33794 41ef3dc95179
parent 33604 ad1cd9269bd4
child 37248 11a660dbbb8e
--- a/hotspot/src/share/vm/utilities/xmlstream.cpp	Mon Nov 09 11:35:45 2015 +0000
+++ b/hotspot/src/share/vm/utilities/xmlstream.cpp	Mon Oct 26 16:21:37 2015 +0100
@@ -346,13 +346,16 @@
 // ------------------------------------------------------------------
 void xmlStream::va_done(const char* format, va_list ap) {
   char buffer[200];
-  guarantee(strlen(format) + 10 < sizeof(buffer), "bigger format buffer");
+  size_t format_len = strlen(format);
+  guarantee(format_len + 10 < sizeof(buffer), "bigger format buffer");
   const char* kind = format;
   const char* kind_end = strchr(kind, ' ');
-  size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : strlen(kind);
+  size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : format_len;
   strncpy(buffer, kind, kind_len);
   strcpy(buffer + kind_len, "_done");
-  strcat(buffer, format + kind_len);
+  if (kind_end != NULL) {
+    strncat(buffer, format + kind_len, sizeof(buffer) - (kind_len + 5 /* _done */) - 1);
+  }
   // Output the trailing event with the timestamp.
   va_begin_elem(buffer, ap);
   stamp();