summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2009-12-17 01:16:15 +0000
committerJuri Linkov <juri@jurta.org>2009-12-17 01:16:15 +0000
commitad974e9e13ab6f9ece2c7558cef99e743e07743f (patch)
tree719cb01bfa6e0e010948a6a066e775839c8f47bd
parentf7c66b8bf8d750502c4e83c8870e4ddf0d3addb5 (diff)
downloademacs-ad974e9e13ab6f9ece2c7558cef99e743e07743f.tar.gz
emacs-ad974e9e13ab6f9ece2c7558cef99e743e07743f.tar.bz2
emacs-ad974e9e13ab6f9ece2c7558cef99e743e07743f.zip
Make `dired-diff' more safe. (Bug#5225)
* dired-aux.el (dired-diff): Signal an error when `file' equals to `current' or when `file' is a directory of the `current' file.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/dired-aux.el9
2 files changed, 15 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 24aea22138c..c2a166435d0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2009-12-17 Juri Linkov <juri@jurta.org>
+
+ Make `dired-diff' more safe. (Bug#5225)
+
+ * dired-aux.el (dired-diff): Signal an error when `file' equals to
+ `current' or when `file' is a directory of the `current' file.
+
2009-12-17 Andreas Schwab <schwab@linux-m68k.org>
* emacs-lisp/autoload.el (batch-update-autoloads): Only exclude
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index d3f5de72c7f..d42aca93ebd 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -90,7 +90,14 @@ which is options for `diff'."
(if (stringp diff-switches)
diff-switches
(mapconcat 'identity diff-switches " ")))))))
- (diff file (dired-get-filename t) switches))
+ (let ((current (dired-get-filename t)))
+ (when (or (equal (expand-file-name file)
+ (expand-file-name current))
+ (and (file-directory-p file)
+ (equal (expand-file-name current file)
+ (expand-file-name current))))
+ (error "Attempt to compare the file to itself"))
+ (diff file current switches)))
;;;###autoload
(defun dired-backup-diff (&optional switches)