RFR: 8148005: One byte may be corrupted by get_datetime_string()

Artem Smotrakov artem.smotrakov at oracle.com
Wed Feb 3 23:53:00 UTC 2016


Hello,

Please review this small one-line patch which fixes a potential one-byte 
corruption outside a buffer in get_datetime_string() function.

diff -r 9fc51379c2c0 src/share/vm/utilities/ostream.cpp
--- a/src/share/vm/utilities/ostream.cpp    Wed Feb 03 18:48:29 2016 +0000
+++ b/src/share/vm/utilities/ostream.cpp    Wed Feb 03 15:52:28 2016 -0800
@@ -380,7 +380,7 @@
  char* get_datetime_string(char *buf, size_t len) {
    os::local_time_string(buf, len);
    int i = (int)strlen(buf);
-  while (i-- >= 0) {
+  while (--i >= 0) {
      if (buf[i] == ' ') buf[i] = '_';
      else if (buf[i] == ':') buf[i] = '-';
    }

Bug: https://bugs.openjdk.java.net/browse/JDK-8148005
Webrev: http://cr.openjdk.java.net/~asmotrak/8148005/webrev.00/

Artem


More information about the hotspot-runtime-dev mailing list