https://bz.apache.org/bugzilla/show_bug.cgi?id=62849

--- Comment #4 from Jaikiran Pai <[email protected]> ---
Hello Michael,

I haven't thoroughly reviewed the patch or checked the implication of the
change. However, this change:

--- src/main/org/apache/tools/ant/DirectoryScanner.java (date 1531197234000)
+++ src/main/org/apache/tools/ant/DirectoryScanner.java (date 1540366425000)
@@ -1258,6 +1258,18 @@ 
             final String name = vpath + newFile;
             final TokenizedPath newPath = new TokenizedPath(path, newFile);
             final File file = new File(dir, newFile);
+
+            try {
+                String fileCanonicalPath = file.getCanonicalPath();
+                String dirCanonicalPath = dir.getCanonicalPath();
+                if (dirCanonicalPath.startsWith(fileCanonicalPath)) {
+                    continue;
+                }
+            } catch (IOException e) {
+                System.err.println("Failed to get canoncial paths to determine
" +
+                    "if filesyste loop exists, continuning");
+            }
+


Could you instead try something like this (just pseudo-code, haven't checked
for compile errors):

            try {
                if
(FileUtils.getFileUtils().isLeadingPath(file.getAbsoluteFile(),
dir.getAbsoluteFile(), true)) {
                    continue;
                }
            } catch (IOException e) {
                // log it
            }

The FileUtils#isLeadingPath with resolveSymlink = true would do the same as
what you have attempted in the patch.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to