This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 9794395 Make calculation of session storage location more robust 9794395 is described below commit 97943959ba721ad5e8e8ba765a68d2b153348530 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 d7ede19..5d2f978 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -145,6 +145,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