Browse Source

don't assume File#isDirectory == !File#isFile - i.e. explicitly test

and drop objects that are neither files nor directories.  PR 56149



git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1573999 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 11 years ago
parent
commit
bea36bbd2b
2 changed files with 13 additions and 4 deletions
  1. +6
    -0
      WHATSNEW
  2. +7
    -4
      src/main/org/apache/tools/ant/DirectoryScanner.java

+ 6
- 0
WHATSNEW View File

@@ -20,6 +20,12 @@ Changes that could break older environments:
only on platforms with multiple file syste roots.
Bugzilla Report 53949

* DirectoryScanner and thus fileset/dirset will now silently drop all
filesystem objects that are neither files nor directories according
to java.io.File. This prevents Ant from reading named pipes which
might lead to blocking or other undefined behavior.
Bugzilla Report 56149

Fixed bugs:
-----------



+ 7
- 4
src/main/org/apache/tools/ant/DirectoryScanner.java View File

@@ -1022,7 +1022,7 @@ public class DirectoryScanner
} else {
scandir(myfile, currentPath, true);
}
} else {
} else if (myfile.isFile()) {
String originalpattern = (String) entry.getValue();
boolean included = isCaseSensitive()
? originalpattern.equals(currentelement)
@@ -1222,8 +1222,11 @@ public class DirectoryScanner
if (SYMLINK_UTILS.isSymbolicLink(dir, newfiles[i])) {
String name = vpath + newfiles[i];
File file = new File(dir, newfiles[i]);
(file.isDirectory()
? dirsExcluded : filesExcluded).addElement(name);
if (file.isDirectory()) {
dirsExcluded.addElement(name);
} else if (file.isFile()) {
filesExcluded.addElement(name);
}
accountForNotFollowedSymlink(name, file);
} else {
noLinks.add(newfiles[i]);
@@ -1253,7 +1256,7 @@ public class DirectoryScanner
everythingIncluded = false;
filesNotIncluded.addElement(name);
}
} else { // dir
} else if (file.isDirectory()) { // dir

if (followSymlinks
&& causesIllegalSymlinkLoop(newfiles[i], dir,


Loading…
Cancel
Save