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

Andrea Cosentino resolved CAMEL-25023.
--------------------------------------
    Resolution: Fixed

Fixed on all supported lines:

* main (4.23.0): https://github.com/apache/camel/pull/26892
* camel-4.22.x (4.22.2): https://github.com/apache/camel/pull/27137
* camel-4.18.x (4.18.5): https://github.com/apache/camel/pull/27138

The two backports are straight cherry-picks of #26892. The matching 4.22 and 
4.18 upgrade-guide entries are synced on main in 
https://github.com/apache/camel/pull/27140.

_Claude Code on behalf of oscerd_

> camel-util - IOHelper.copy counts copied bytes in an int, so zipFile/tarFile 
> maxDecompressedSize values of 2 GiB or more are not enforced
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25023
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25023
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core, camel-tarfile, camel-zipfile
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Major
>             Fix For: 4.18.5, 4.22.2, 4.23.0
>
>
> {{IOHelper.copy(InputStream, OutputStream, int bufferSize, boolean 
> flushOnEachWrite, long maxSize)}} keeps its running byte count in an {{int}}:
> {code:java}
> int total = 0;
> ...
> total += n;
> if (maxSize > 0 && total > maxSize) {
>     throw new IOException("The InputStream entry being copied exceeds the 
> maximum allowed size");
> }
> {code}
> An {{int}} cannot exceed {{Integer.MAX_VALUE}} and wraps to a negative value 
> after 2 GiB, so a {{maxSize}} of {{Integer.MAX_VALUE}} or larger (or within 
> one read buffer below it) never triggers the check. The {{int}} return value 
> is also negative for copies larger than 2 GiB.
> This overload implements the {{maxDecompressedSize}} option of:
> * {{ZipFileDataFormat.unmarshal}} ({{usingIterator=false}})
> * {{ZipIterator}} / {{ZipSplitter}} ({{usingIterator=true}}, since 
> CAMEL-24166)
> * {{TarFileDataFormat.unmarshal}} ({{usingIterator=false}})
> {{maxDecompressedSize}} is a {{java.lang.Long}} option; the 1 GiB default is 
> enforced correctly, but values of 2 GiB or more are currently ignored. 
> {{TarIterator}} is not affected, as it uses a long-based 
> {{BoundedInputStream}}.
> Proposed change:
> * count in a {{long}} and return {{(int) Math.min(total, 
> Integer.MAX_VALUE)}}, keeping the public signature;
> * regression test in {{IOHelperTest}}: copy 3 GiB of synthetic zeros into a 
> discarding {{OutputStream}} with {{maxSize}} = 2 GiB and expect the 
> {{IOException}} (needs no heap or disk).
> _Claude Code on behalf of oscerd_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to