You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stefan Bodewig (JIRA)" <ji...@apache.org> on 2018/05/04 04:07:00 UTC

[jira] [Resolved] (COMPRESS-451) IOUtils.copy hangs with misconfigured or corrupted inputs

     [ https://issues.apache.org/jira/browse/COMPRESS-451?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bodewig resolved COMPRESS-451.
-------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.17

fixed with git commit 0aeda4fc, thanks!

> 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
>            Priority: Major
>             Fix For: 1.17
>
>
> 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)