This is an automated email from the ASF dual-hosted git repository. remm 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 684b2290a6 Fix possible partial corrupted file copies 684b2290a6 is described below commit 684b2290a657f2b5513c3189265118472caf5f90 Author: remm <r...@apache.org> AuthorDate: Fri Apr 28 15:19:42 2023 +0200 Fix possible partial corrupted file copies PR#613 submitted by Jack Shirazi --- java/org/apache/catalina/startup/ExpandWar.java | 13 ++++++++++++- webapps/docs/changelog.xml | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/java/org/apache/catalina/startup/ExpandWar.java b/java/org/apache/catalina/startup/ExpandWar.java index b2f6e58895..4d7cf78e85 100644 --- a/java/org/apache/catalina/startup/ExpandWar.java +++ b/java/org/apache/catalina/startup/ExpandWar.java @@ -17,6 +17,7 @@ package org.apache.catalina.startup; import java.io.BufferedOutputStream; +import java.io.EOFException; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -268,7 +269,17 @@ public class ExpandWar { } else { try (FileChannel ic = (new FileInputStream(fileSrc)).getChannel(); FileChannel oc = (new FileOutputStream(fileDest)).getChannel()) { - ic.transferTo(0, ic.size(), oc); + long size = ic.size(); + long position = 0; + while (size > 0) { + long count = ic.transferTo(position, size, oc); + if (count > 0) { + position += count; + size -= count; + } else { + throw new EOFException(); + } + } } catch (IOException e) { log.error(sm.getString("expandWar.copy", fileSrc, fileDest), e); result = false; diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 95a59f8812..7bd6ea22ae 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -129,6 +129,11 @@ like for headers and attributes. Those will be logged as sub objects. (rjung) </update> + <fix> + <pr>613</pr>: Fix possible partial corrupted file copies when using + file lockig protection or the manager servlet. Submitted + by Jack Shirazi. (remm) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org