ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: Stefano - [PATCH] Prevents infinite dir recursion in Ant
Date Thu, 16 Mar 2000 23:58:33 GMT
Robin Green wrote:
> 
> Could you check this in please? I haven't got time to subscribe to the
> mailing lists unfortunately. PS. Cocoon rocks!

I'll forward this to the mail list. This is all I want to do about it.
 
> ---
> /home/ufs1/12/greenrd/tmp/cvs-ant/src/main/org/apache/tools/ant/DirectoryScanner.java
  Thu
> Mar 16 23:16:24 2000
> +++
> /home/ufs1/12/greenrd/tmp/cvs-ant/src/main/org/apache/tools/ant/DirectoryScanner.java.orig
     Thu
> Mar 16 23:04:42 2000
> @@ -132,8 +132,6 @@
>   * .class files in all directories under a directory called "modules"
>   *
>   * @author Arnout J. Kuiper <a
> href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>
> - * @author Robin D. Green
> - *   <a href="mailto:greenrd@hotmail.com">greenrd@hotmail.com</a>
>   */
> public class DirectoryScanner {
> 
> @@ -200,26 +198,6 @@
>       */
>      private Vector dirsExcluded;
> 
> -    /**
> -     * If this is true, symlinks that point to a parent of themselves will
> -     * be followed maximally, until directories that have already been
> -     * scanned are reached. (Actually, the current method may repeat
> files.)
> -     * If false, they will not be followed at all.
> -     * Setting this to true is not recommended as it may drastically
> -     * increase the time required.
> -     * False by default.
> -     *
> -     * @see setMinLoopDetect(boolean)
> -     */
> -    private boolean minLoopDetect = false;
> -
> -    /**
> -     * When in minLoopDetect mode, this holds "looping" symlinks that have
> -     * already been traversed, to prevent them being traversed again.
> -     * This acts like a HashSet.
> -     */
> -    private Hashtable loopingSymlinks;
> -
> 
>      /**
> @@ -598,21 +576,6 @@
> 
>      /**
> -     * If minLoopDetect is true, symlinks that point to a parent of
> -     * themselves will be followed maximally, until directories that have
> -     * already been scanned are reached.
> -     * If false, they will not be followed at all.
> -     * Setting minLoopDetect to true is not recommended as it may
> drastically
> -     * increase the time required.
> -     * False by default.
> -     */
> -    public void setMinLoopDetect (boolean minLoopDetect) {
> -        this.minLoopDetect = minLoopDetect;
> -    }
> -
> -
> -
> -    /**
>       * Scans the base directory for files that match at least one include
>       * pattern, and don't match any exclude patterns.
>       *
> @@ -645,9 +608,6 @@
>          dirsNotIncluded  = new Vector();
>          dirsExcluded     = new Vector();
> 
> -        if (minLoopDetect)
> -            loopingSymlinks = new Hashtable();
> -
>          scandir(basedir,"");
>      }
> 
> @@ -671,34 +631,6 @@
>       * @see #dirsExcluded
>       */
>      private void scandir(File dir, String vpath) {
> -
> -        /*
> -         * RDG: Prevent "infinite" recursion if a symlink points to a
> parent
> -         * of itself.
> -         * (Okay, making such a symlink might not be very sensible,
> -         * but the user may have good reasons for doing this, and
> -         * indefinite looping isn't desirable behaviour.)
> -         */
> -        try {
> -            String canonicalDir = dir.getCanonicalPath ();
> -            File parentFile = new File (dir.getParent ());
> -            String canonicalParent = parentFile.getCanonicalPath ();
> -            boolean loopFound = canonicalParent.startsWith (canonicalDir);
> -
> -            if (loopFound) {           // symlink recursion detected
> -                if (minLoopDetect) {
> -                    if (loopingSymlinks.contains (canonicalDir)) {
> -                        return;        // We've been here already
> -                    }
> -                    loopingSymlinks.put (canonicalDir, canonicalDir);
> -                }
> -                return;                // Don't bother following it
> -            }
> -        } catch (IOException ex) {
> -            // dir doesn't appear to exist anyway
> -            return;
> -        }
> -
>          String[] newfiles = dir.list();
>          for (int i = 0; i < newfiles.length; i++) {
>              String name = vpath+newfiles[i];
> 
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com


-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------

Mime
View raw message