# HG changeset patch # User dsamersoff # Date 1312974261 -14400 # Node ID 46cb9a7b8b017ff3c00795cd5f776e92860740f1 # Parent ca1f1753c866091f33fde7b8308454029b9121fe 7073913: The fix for 7017193 causes segfaults Summary: Buffer overflow in os::get_line_chars Reviewed-by: coleenp, dholmes, dcubed Contributed-by: aph@redhat.com diff -r ca1f1753c866 -r 46cb9a7b8b01 src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp Thu Jul 28 14:10:21 2011 -0400 +++ b/src/share/vm/runtime/os.cpp Wed Aug 10 15:04:21 2011 +0400 @@ -1299,7 +1299,7 @@ size_t sz, i = 0; // read until EOF, EOL or buf is full - while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-1) && buf[i] != '\n') { + while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-2) && buf[i] != '\n') { ++i; } @@ -1320,7 +1320,7 @@ } // line is longer than size of buf, skip to EOL - int ch; + char ch; while (read(fd, &ch, 1) == 1 && ch != '\n') { // Do nothing }