Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-157

Wrong EOF detection in CBZip2InputStream

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None

      Description

      The following snippet form CBZip2InputStream does a wrong EOF check. The char 'thech' will never be equal to the integer '-1'. You have to check for #read() returning -1 before casting to char.

      I found the bug in http://svn.wikimedia.org/svnroot/mediawiki/trunk/mwdumper/src/org/apache/commons/compress/bzip2/ not in your TRUNK.

                                  int zzi;
                                  char thech = 0;
                                  try
                                  {
                                      thech = (char)m_input.read();
                                  }
                                  catch( IOException e )
                                  {
                                      compressedStreamEOF();
                                  }
                                  if( thech == -1 ) //HERE
                                  {
                                      compressedStreamEOF();
                                  }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jtheuer Jan
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: