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

IOUtils.copy hangs with misconfigured or corrupted inputs

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.17
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: