7073913: The fix for 7017193 causes segfaults

Wed, 10 Aug 2011 15:04:21 +0400

author
dsamersoff
date
Wed, 10 Aug 2011 15:04:21 +0400
changeset 3030
46cb9a7b8b01
parent 3020
ca1f1753c866
child 3033
a68e11dceb83

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 file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/runtime/os.cpp	Thu Jul 28 14:10:21 2011 -0400
     1.2 +++ b/src/share/vm/runtime/os.cpp	Wed Aug 10 15:04:21 2011 +0400
     1.3 @@ -1299,7 +1299,7 @@
     1.4    size_t sz, i = 0;
     1.5  
     1.6    // read until EOF, EOL or buf is full
     1.7 -  while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-1) && buf[i] != '\n') {
     1.8 +  while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-2) && buf[i] != '\n') {
     1.9       ++i;
    1.10    }
    1.11  
    1.12 @@ -1320,7 +1320,7 @@
    1.13    }
    1.14  
    1.15    // line is longer than size of buf, skip to EOL
    1.16 -  int ch;
    1.17 +  char ch;
    1.18    while (read(fd, &ch, 1) == 1 && ch != '\n') {
    1.19      // Do nothing
    1.20    }

mercurial