diff --git a/WHATSNEW b/WHATSNEW index 879f243d2..56336601a 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -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: ----------- diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java index 1c67f3f6f..f28f90944 100644 --- a/src/main/org/apache/tools/ant/DirectoryScanner.java +++ b/src/main/org/apache/tools/ant/DirectoryScanner.java @@ -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,