From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#5225: dired-diff should be more safe Date: Wed, 16 Dec 2009 11:19:09 +0200 Organization: JURTA Message-ID: <87vdg7cm42.fsf@mail.jurta.org> Reply-To: Juri Linkov , 5225@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1260956886 14421 80.91.229.12 (16 Dec 2009 09:48:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Dec 2009 09:48:06 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 16 10:47:59 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NKqUA-0008BD-2J for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Dec 2009 10:47:58 +0100 Original-Received: from localhost ([127.0.0.1]:35143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKqUA-0004GZ-4T for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Dec 2009 04:47:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKqTq-000403-RC for bug-gnu-emacs@gnu.org; Wed, 16 Dec 2009 04:47:38 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKqTl-0003r7-P4 for bug-gnu-emacs@gnu.org; Wed, 16 Dec 2009 04:47:38 -0500 Original-Received: from [199.232.76.173] (port=53414 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKqTl-0003qe-B0 for bug-gnu-emacs@gnu.org; Wed, 16 Dec 2009 04:47:33 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:51506) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NKqTk-0002fj-G5 for bug-gnu-emacs@gnu.org; Wed, 16 Dec 2009 04:47:32 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nBG9lT0c007547; Wed, 16 Dec 2009 01:47:30 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nBG9e7QP006744; Wed, 16 Dec 2009 01:40:07 -0800 Resent-Date: Wed, 16 Dec 2009 01:40:07 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Juri Linkov Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Wed, 16 Dec 2009 09:40:06 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 5225 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12609560336137 (code B ref -1); Wed, 16 Dec 2009 09:40:06 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 16 Dec 2009 09:33:53 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nBG9Xpax006134 for ; Wed, 16 Dec 2009 01:33:52 -0800 Original-Received: from mx10.gnu.org ([199.232.76.166]:46709) by fencepost.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NKqGU-0002y7-MR for emacs-pretest-bug@gnu.org; Wed, 16 Dec 2009 04:33:50 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NKqGR-0001Af-UT for emacs-pretest-bug@gnu.org; Wed, 16 Dec 2009 04:33:50 -0500 Original-Received: from smtp-out3.starman.ee ([85.253.0.5]:45080 helo=mx1.starman.ee) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NKqGR-0001AZ-IU for emacs-pretest-bug@gnu.org; Wed, 16 Dec 2009 04:33:47 -0500 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.94.242.cable.starman.ee [82.131.94.242]) by mx1.starman.ee (Postfix) with ESMTP id D06C23F41E9 for ; Wed, 16 Dec 2009 11:33:41 +0200 (EET) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Wed, 16 Dec 2009 04:47:38 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:33627 gmane.emacs.pretest.bugs:25329 Archived-At: 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/