From ad974e9e13ab6f9ece2c7558cef99e743e07743f Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 17 Dec 2009 01:16:15 +0000 Subject: [PATCH] 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. --- lisp/ChangeLog | 7 +++++++ lisp/dired-aux.el | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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 + + 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 * 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) -- 2.11.4.GIT