GNU bug report logs -
#5225
dired-diff should be more safe
Previous Next
Reported by: Juri Linkov <juri <at> jurta.org>
Date: Wed, 16 Dec 2009 09:40:06 UTC
Severity: normal
Done: Juri Linkov <juri <at> jurta.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
This is an automatic notification regarding your bug report
which was filed against the emacs package:
#5225: dired-diff should be more safe
It has been closed by Juri Linkov <juri <at> jurta.org>.
Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Juri Linkov <juri <at> jurta.org> by
replying to this email.
--
5225: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5225
Emacs Bug Tracking System
Contact bug-gnu-emacs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Fixed.
--
Juri Linkov
http://www.jurta.org/emacs/
[Message part 3 (message/rfc822, inline)]
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)
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)
--
Juri Linkov
http://www.jurta.org/emacs/
This bug report was last modified 15 years and 184 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.