[Top][All Lists]

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

[Emacs-bug-tracker] bug#5225: marked as done (dired-diff should be more

From: Emacs bug Tracking System
Subject: [Emacs-bug-tracker] bug#5225: marked as done (dired-diff should be more safe)
Date: Fri, 18 Dec 2009 07:33:03 +0000

Your message dated Thu, 17 Dec 2009 03:19:27 +0200
with message-id <address@hidden>
and subject line Re: bug#5225: dired-diff should be more safe
has caused the Emacs bug report #5225,
regarding dired-diff should be more safe
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact address@hidden

5225: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5225
Emacs Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: dired-diff should be more safe Date: Wed, 16 Dec 2009 11:19:09 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (x86_64-pc-linux-gnu)
Currently using `dired-diff' has a high risk of deleting a file.

When two compared file names refer to the same file, or when one of them
is the directory name of the second file (thus the file is compared
against itself), then the user may not notice that `diff' compares the
same file with itself, and when `diff' says there are no differences,
decide to delete the file (thinking that two files have the same content).

The patch below eliminates this risk by signalling an error when
comparing the same file to itself:

=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el   2009-11-25 17:15:19 +0000
+++ lisp/dired-aux.el   2009-12-16 09:16:34 +0000
@@ -60,27 +60,44 @@
                       (if (stringp 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)))
 (defun dired-backup-diff (&optional switches)

Juri Linkov

--- End Message ---
--- Begin Message --- Subject: Re: bug#5225: dired-diff should be more safe Date: Thu, 17 Dec 2009 03:19:27 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (x86_64-pc-linux-gnu)

Juri Linkov

--- End Message ---

reply via email to

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