commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Doe (JIRA)" <j...@apache.org>
Subject [jira] [Created] (COMPRESS-451) IOUtils.copy hangs with misconfigured or corrupted inputs
Date Thu, 03 May 2018 21:50:00 GMT
John Doe created COMPRESS-451:
---------------------------------

             Summary: IOUtils.copy hangs with misconfigured or corrupted inputs
                 Key: COMPRESS-451
                 URL: https://issues.apache.org/jira/browse/COMPRESS-451
             Project: Commons Compress
          Issue Type: Bug
    Affects Versions: 1.0
            Reporter: John Doe


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

{code:java}
    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;
    }
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message