From c275ed3718b70e9c6daffb96617b1846eb1d5243 Mon Sep 17 00:00:00 2001 From: dsamersoff Date: Wed, 10 Aug 2011 15:04:21 +0400 Subject: [PATCH] 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 --- src/share/vm/runtime/os.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp index 5da110807..28c655951 100644 --- a/src/share/vm/runtime/os.cpp +++ b/src/share/vm/runtime/os.cpp @@ -1299,7 +1299,7 @@ int os::get_line_chars(int fd, char* buf, const size_t bsize){ 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 @@ int os::get_line_chars(int fd, char* buf, const size_t bsize){ } // line is longer than size of buf, skip to EOL - int ch; + char ch; while (read(fd, &ch, 1) == 1 && ch != '\n') { // Do nothing } -- GitLab