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

IOUtils.copy hangs with misconfigured or corrupted inputs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0
    • 1.17
    • None
    • None

    Description

      When the buffersize is misconfigured or corrupted, i.e., 0, the while loop in IOUtils.copy() function hangs endlessly. Here is the code snippet.

          public static long copy(final InputStream input, final OutputStream output, int buffersize) throws IOException {
              final byte[] buffer = new byte[buffersize];//buffersize is misconfigured or corrupted
              int n = 0;
              long count=0;
              while (-1 != (n = input.read(buffer))) {//input.read returns 0 when buffer.length==0
                  output.write(buffer, 0, n);
                  count += n;
              }
              return count;
          }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            dustinday John Doe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: