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 1385c62 Make calculation of session storage location more robust 1385c62 is described below commit 1385c624b4a1e994426e810075c850edc38a700e Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jan 12 11:11:29 2022 +0000 Make calculation of session storage location more robust --- java/org/apache/catalina/session/FileStore.java | 5 +++-- webapps/docs/changelog.xml | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/session/FileStore.java b/java/org/apache/catalina/session/FileStore.java index cac6027..e42a72a 100644 --- a/java/org/apache/catalina/session/FileStore.java +++ b/java/org/apache/catalina/session/FileStore.java @@ -349,13 +349,14 @@ public final class FileStore extends StoreBase { String filename = id + FILE_EXT; File file = new File(storageDir, filename); + File canonicalFile = file.getCanonicalFile(); // Check the file is within the storage directory - if (!file.getCanonicalFile().toPath().startsWith(storageDir.getCanonicalFile().toPath())) { + if (!canonicalFile.toPath().startsWith(storageDir.getCanonicalFile().toPath())) { log.warn(sm.getString("fileStore.invalid", file.getPath(), id)); return null; } - return file; + return canonicalFile; } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index c5576c0..4944f93 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -118,6 +118,10 @@ <update> Remove the deprecated <code>JmxRemoteLifecycleListener</code>. (markt) </update> + <fix> + Make the calculation of the session storage location more robust when + using file based persistent storage. (markt) + </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