bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fts: avoid false-positive cycle-detection


From: James Youngman
Subject: Re: [PATCH] fts: avoid false-positive cycle-detection
Date: Mon, 27 Jul 2009 00:46:39 +0100

On Sun, Jul 19, 2009 at 9:35 PM, Jim Meyering<address@hidden> wrote:
> I'm considering a rewrite of rm that uses fts.c,
> and see that the resulting rm fails coreutils' rm/cycle test
> because it incorrectly reports a cycle for that unusual case.
>
> The following patch fixes fts so that it properly reinitializes one of
> its cycle-detection data structure for each new command line argument.
>
> I might save a little by merely clearing the hash table
> and reusing it, rather than freeing it altogether, but don't
> think that would be worth the added code.
>
> I have not yet been able to cause trouble with chmod, chown, chcon,
> or du, but haven't tried very hard, either.

>From your description, I would have assumed that find would be
affected, but this appears not to be the case:

$ ./find/find  ~/tmp/a  ~/tmp/a
/home/james/tmp/a
/home/james/tmp/a/file
/home/james/tmp/a
/home/james/tmp/a/file


>
> From a90d85f9e7ca8329d05bb7dd02cf807b9086b71e Mon Sep 17 00:00:00 2001
> From: Jim Meyering <address@hidden>
> Date: Sun, 19 Jul 2009 22:33:09 +0200
> Subject: [PATCH] fts: avoid false-positive cycle-detection
>
> * lib/fts.c (fts_read): Reinitialize cycle-detection data structures
> for each new command line argument.
> ---
>  ChangeLog |    6 ++++++
>  lib/fts.c |    2 ++
>  2 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 56a6bda..9c78852 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,9 @@
> +2009-07-19  Jim Meyering  <address@hidden>
> +
> +       fts: avoid false-positive cycle-detection
> +       * lib/fts.c (fts_read): Reinitialize cycle-detection data structures
> +       for each new command line argument.
> +
>  2009-07-19  Bruno Haible  <address@hidden>
>
>        Fix build error on mingw with the modules sys_select and unistd.
> diff --git a/lib/fts.c b/lib/fts.c
> index 0cbb9fb..bbcd1ff 100644
> --- a/lib/fts.c
> +++ b/lib/fts.c
> @@ -932,7 +932,9 @@ next:       tmp = p;
>                                SET(FTS_STOP);
>                                return (NULL);
>                        }
> +                       free_dir(sp);
>                        fts_load(sp, p);
> +                       setup_dir(sp);
>                        goto check_for_dir;
>                }
>
> --
> 1.6.4.rc1.169.gd0406
>
>
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]