From juri@jurta.org Wed Dec 16 01:33:52 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 16 Dec 2009 09:33:53 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-1.2 required=4.0 tests=AWL,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 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 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 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 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 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) From: Juri Linkov To: emacs-pretest-bug@gnu.org Subject: dired-diff should be more safe Organization: JURTA Date: Wed, 16 Dec 2009 11:19:09 +0200 Message-ID: <87vdg7cm42.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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/ From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 18 02:32:29 2009 Received: (at 5225-done) by debbugs.gnu.org; 18 Dec 2009 07:32:29 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NLXK8-0002nV-UT for submit@debbugs.gnu.org; Fri, 18 Dec 2009 02:32:28 -0500 Received: from smtp-out3.starman.ee ([85.253.0.5] helo=mx1.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NLWL4-0002Gz-84 for 5225-done@emacsbugs.donarmstrong.com; Fri, 18 Dec 2009 01:29:22 -0500 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Received: from mail.starman.ee (82.131.31.103.cable.starman.ee [82.131.31.103]) by mx1.starman.ee (Postfix) with ESMTP id 731383F410E for <5225-done@emacsbugs.donarmstrong.com>; Thu, 17 Dec 2009 04:07:27 +0200 (EET) From: Juri Linkov To: 5225-done@debbugs.gnu.org Subject: Re: bug#5225: dired-diff should be more safe Organization: JURTA References: <87vdg7cm42.fsf@mail.jurta.org> Date: Thu, 17 Dec 2009 03:19:27 +0200 In-Reply-To: <87vdg7cm42.fsf@mail.jurta.org> (Juri Linkov's message of "Wed, 16 Dec 2009 11:19:09 +0200") Message-ID: <87eimubdnm.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Debbugs-Envelope-To: 5225-done X-Mailman-Approved-At: Fri, 18 Dec 2009 02:32:26 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org Fixed. -- Juri Linkov http://www.jurta.org/emacs/ From unknown Sat Jun 14 19:05:00 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 15 Jan 2010 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # A New Hope # A long time ago, in a galaxy far, far away # something happened. # # Magically this resulted in the following # action being taken, but this fake control # message doesn't tell you why it happened # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator