janhoy commented on a change in pull request #593: URL: https://github.com/apache/solr/pull/593#discussion_r798960272
########## File path: solr/core/src/java/org/apache/solr/filestore/DistribPackageStore.java ########## @@ -94,8 +94,18 @@ private static Path _getRealPath(String path, Path solrHome) { if (!path.isEmpty() && path.charAt(0) != File.separatorChar) { path = File.separator + path; } - // Use concat because path might start with a slash and be incorrectly interpreted as absolute - return solrHome.resolve(PackageStoreAPI.PACKAGESTORE_DIRECTORY + path); + if (path.startsWith("\\\\")) { // Windows absolute UNC + throw new SolrException(BAD_REQUEST, "Illegal path " + path); + } + while (path.startsWith("/")) { // Trim all leading slashes Review comment: > I specifically remember getting bit by this in [ab6e695](https://github.com/apache/solr/commit/ab6e695973ca8cc4c8161ef9ec07d3749bf0870f) Yes, the Path API is a bit sneaky there. I'd ideally convert all those String representations of filesystem paths in the pkgMgr into Paths, but that's out of scope for this. The test code uses strings with leading slashes as meaning "root of the file store", so that's why I strip all leading slashes (path-sep) so that the resolve is always relative, and in addition double check that we are not outside the filestore root. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org