commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (COMPRESS-451) IOUtils.copy hangs with misconfigured or corrupted inputs
Date Fri, 04 May 2018 04:07:00 GMT

     [ 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)

Mime
View raw message