[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarch
From: |
Eli Zaretskii |
Subject: |
bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy |
Date: |
Fri, 13 Jan 2012 09:23:57 +0200 |
> From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
> Date: Thu, 12 Jan 2012 22:33:38 +0100
>
> Hi, here a patch that should fix this.
Thanks.
> + (when (string= (file-name-as-directory from)
> + (file-name-as-directory to))
> + (error "Can't copy to same directory"))
> (let ((attrs (file-attributes from)))
> (if (and recursive
> (eq t (car attrs))
> @@ -1431,7 +1434,10 @@
> (marker-char (dired-file-marker from)) ; slow
> (t nil))))
> (when (and (file-directory-p from)
> - (file-directory-p to)
> + (or (file-directory-p to)
> + (string= (file-name-as-directory from)
> + (file-name-as-directory
> + (file-name-directory to))))
> (eq file-creator 'dired-copy-file))
> (setq to (file-name-directory to)))
> (condition-case err
> diff --git a/lisp/files.el b/lisp/files.el
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -4928,6 +4928,9 @@
> (format "Copy directory %s to: " dir)
> default-directory default-directory nil nil)
> current-prefix-arg t nil)))
> + (when (string= (file-name-as-directory directory)
> + (file-name-as-directory newname))
> + (error "Can't copy to same directory"))
> ;; If default-directory is a remote directory, make sure we find its
> ;; copy-directory handler.
> (let ((handler (or (find-file-name-handler directory 'copy-directory)
I don't think this will solves all the use cases. File names are not
strings, you cannot compare them as literal strings and hope to plumb
all the leaks.
Some situations which I think this patch will not handle correctly:
. file names with different letter-case on a case-insensitive file
system
. relative vs absolute file names
. file names that are hard links to the same directory (this includes
the infamous 8+3 short aliases on Windows)
I didn't actually try the patch, so apologies if I missed something
which makes these non-issues.
Thanks again for working on this.
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Michael Heerdegen, 2012/01/12
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Thierry Volpiatto, 2012/01/12
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy,
Eli Zaretskii <=
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Thierry Volpiatto, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Eli Zaretskii, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Thierry Volpiatto, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Juanma Barranquero, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Eli Zaretskii, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Michael Albinus, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Juanma Barranquero, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Juanma Barranquero, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Juanma Barranquero, 2012/01/13
- bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy, Michael Albinus, 2012/01/13