This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 8d22121fa1 Improve handling of overflow
8d22121fa1 is described below
commit 8d22121fa1121142f8fba95ee330ef42515c047d
Author: Mark Thomas <[email protected]>
AuthorDate: Sun Apr 7 22:01:20 2024 +0200
Improve handling of overflow
---
java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
index 807ef7bae6..699a10a46b 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -291,6 +291,7 @@ public class DiskFileItem
* or {@code null} if the data cannot be read
*
* @throws UncheckedIOException if an I/O error occurs
+ * @throws ArithmeticException if the file {@code size} overflows an int
*/
@Override
public byte[] get() throws UncheckedIOException {
@@ -301,7 +302,7 @@ public class DiskFileItem
return cachedContent != null ? cachedContent.clone() : new byte[0];
}
- final byte[] fileData = new byte[(int) getSize()];
+ final byte[] fileData = new byte[Math.toIntExact(getSize())];
try (InputStream fis = Files.newInputStream(dfos.getFile().toPath())) {
IOUtils.readFully(fis, fileData);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]