]> git.eshelyaron.com Git - emacs.git/commitdiff
Make `dired-diff' more safe. (Bug#5225)
authorJuri Linkov <juri@jurta.org>
Thu, 17 Dec 2009 01:16:15 +0000 (01:16 +0000)
committerJuri Linkov <juri@jurta.org>
Thu, 17 Dec 2009 01:16:15 +0000 (01:16 +0000)
* dired-aux.el (dired-diff): Signal an error when `file' equals to
`current' or when `file' is a directory of the `current' file.

lisp/ChangeLog
lisp/dired-aux.el

index 24aea22138caa2627d89032a0e246c8037dd32f4..c2a166435d04f5ec94b2bb9a0f7166dc8483bf62 100644 (file)
@@ -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
index d3f5de72c7fb2e223d4ce4fd91efcb4eae0cfbd9..d42aca93ebd163af6ae10a29edeebb1f4cf6f133 100644 (file)
@@ -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)