Sometimes, gnu.gcj.convert.BytesToCharsetAdaptor's read method calls
inBuffer.limit(int) with a value that exceeds the buffer capacity.  This can be
easily reproduced when BytesToCharsetAdaptor is used with an input byte aray
that does not have to be decoded from the start, but from a greater possition
(inpos > 0). In this case the line inBuf.limit(inpos + inlength); leads to:

java.lang.IllegalArgumentException
   at java.nio.Buffer.limit(libgcj.so.7)
   at gnu.gcj.convert.BytesToCharsetAdaptor.read(libgcj.so.7)
   at java.lang.String.init(libgcj.so.7)
   at java.lang.String.<init>(libgcj.so.7)
   at BytesToCharsetAdaptorBug.main(BytesToCharsetAdaptorBug.java:6)

Please see the attached example.


-- 
           Summary: gnu.gcj.convert.BytesToCharsetAdaptor calculates bad
                    argument for java.nio.Buffer.limit(int)
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kaloian at doganov dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30600

Reply via email to