You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "John Doe (JIRA)" <ji...@apache.org> on 2018/05/03 21:50:00 UTC
[jira] [Created] (COMPRESS-451) IOUtils.copy hangs with
misconfigured or corrupted inputs
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)