From bea36bbd2b7a2417e4753b7d6760f586e50590cc Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 4 Mar 2014 10:05:43 +0000 Subject: [PATCH] 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 --- WHATSNEW | 6 ++++++ src/main/org/apache/tools/ant/DirectoryScanner.java | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) 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,