public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libgcj/3523: java.io.LineNumberReader has a buggy reset() method.
@ 2001-07-01 22:18 tromey
  0 siblings, 0 replies; 3+ messages in thread
From: tromey @ 2001-07-01 22:18 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, java-prs, jwnimmer, nobody, tromey

Synopsis: java.io.LineNumberReader has a buggy reset() method.

Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Sun Jul  1 22:18:26 2001
Responsible-Changed-Why:
    I'm handling the PR.
State-Changed-From-To: open->closed
State-Changed-By: tromey
State-Changed-When: Sun Jul  1 22:18:26 2001
State-Changed-Why:
    I agree with the enclosed patch and I have checked it in.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3523&database=gcc


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libgcj/3523: java.io.LineNumberReader has a buggy reset() method.
@ 2001-07-01 22:16 Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2001-07-01 22:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR libgcj/3523; it has been noted by GNATS.

From: Tom Tromey <tromey@redhat.com>
To: jwnimmer@alum.mit.edu
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libgcj/3523: java.io.LineNumberReader has a buggy reset() method.
Date: 01 Jul 2001 23:34:25 -0600

 >>>>> "Jeremy" == jwnimmer  <jwnimmer@alum.mit.edu> writes:
 
 Jeremy> -       lineNumber -= countLines(buffer, pos, markPos);
 Jeremy> +       lineNumber -= countLines(buffer, markPos, pos-markPos);
 
 I agree this is correct.
 I am going to check it in and close the PR.
 Thanks for finding and fixing this.
 
 Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

* libgcj/3523: java.io.LineNumberReader has a buggy reset() method.
@ 2001-07-01 19:56 jwnimmer
  0 siblings, 0 replies; 3+ messages in thread
From: jwnimmer @ 2001-07-01 19:56 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3523
>Category:       libgcj
>Synopsis:       java.io.LineNumberReader has a buggy reset() method.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 01 19:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jeremy Nimmer
>Release:        gcc version 3.1 20010630 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu, configured with: configure --enable-threads=posix --enable-shared --enable-languages=c++,java
>Description:
The implementation of the reset() method in java.io.LineNumberReader passes invalid arguments to the countLines method, causing it to index the array out of bounds under certain circumstances.
>How-To-Repeat:
Compile this program to bytecode (with javac, jikes, or gcj) and then run with gij.

import java.io.*;
public class CrashLNR {
  public static void main(String[] args)
    throws Exception
  {
    String s = "123456789\n123456789\n1234\n1234\n";
    LineNumberReader r = new LineNumberReader(new StringReader(s), 35);
    r.readLine();
    r.readLine();
    r.mark(10);
    r.readLine();
    r.reset(); // exception
  }
}
>Fix:
Here is my suggested patch, but I have not tested it thoroughly.

% diff -u LineNumberReader.java LineNumberReader.java.fixed
--- LineNumberReader.java       Tue Mar  7 14:55:26 2000
+++ LineNumberReader.java.fixed Sun Jul  1 22:27:14 2001
@@ -94,7 +94,7 @@
        if (markPos > 0 && pos > markPos && buffer[markPos-1] == '\r'
            && buffer[markPos] == '\n')
          lineNumber--;
-       lineNumber -= countLines(buffer, pos, markPos);
+       lineNumber -= countLines(buffer, markPos, pos-markPos);
        pos = markPos;
       }
   }
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-07-01 22:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-01 22:18 libgcj/3523: java.io.LineNumberReader has a buggy reset() method tromey
  -- strict thread matches above, loose matches on Subject: below --
2001-07-01 22:16 Tom Tromey
2001-07-01 19:56 jwnimmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).