From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#16029: 24.3.50; epa-file.el: decrypted contents get inserted into the wrong buffer Date: Mon, 02 Dec 2013 13:56:40 -0500 Message-ID: References: <87zjojusmb.fsf@debian.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1386010638 13778 80.91.229.3 (2 Dec 2013 18:57:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Dec 2013 18:57:18 +0000 (UTC) Cc: 16029-done@debbugs.gnu.org To: Attila Lendvai Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 02 19:57:23 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VnYgN-00066D-6h for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Dec 2013 19:57:23 +0100 Original-Received: from localhost ([::1]:38357 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnYgM-0002gz-RC for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Dec 2013 13:57:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnYgC-0002fZ-GH for bug-gnu-emacs@gnu.org; Mon, 02 Dec 2013 13:57:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnYg3-00048h-Cu for bug-gnu-emacs@gnu.org; Mon, 02 Dec 2013 13:57:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnYg3-00048b-9P for bug-gnu-emacs@gnu.org; Mon, 02 Dec 2013 13:57:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VnYg3-0007pE-1D for bug-gnu-emacs@gnu.org; Mon, 02 Dec 2013 13:57:03 -0500 Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Dec 2013 18:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 16029 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 16029@debbugs.gnu.org, monnier@iro.umontreal.ca, attila.lendvai@gmail.com Original-Received: via spool by 16029-done@debbugs.gnu.org id=D16029.138601060830053 (code D ref 16029); Mon, 02 Dec 2013 18:57:02 +0000 Original-Received: (at 16029-done) by debbugs.gnu.org; 2 Dec 2013 18:56:48 +0000 Original-Received: from localhost ([127.0.0.1]:55055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VnYfo-0007of-EN for submit@debbugs.gnu.org; Mon, 02 Dec 2013 13:56:48 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:3059) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VnYfm-0007oR-Mm for 16029-done@debbugs.gnu.org; Mon, 02 Dec 2013 13:56:47 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpY5e/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IPAS-Result: Av8EABK/CFFFpY5e/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="40930559" Original-Received: from 69-165-142-94.dsl.teksavvy.com (HELO pastel.home) ([69.165.142.94]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 02 Dec 2013 13:56:40 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 7258562D4B; Mon, 2 Dec 2013 13:56:40 -0500 (EST) In-Reply-To: <87zjojusmb.fsf@debian.lan> (Attila Lendvai's message of "Mon, 02 Dec 2013 22:26:04 +0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:81273 Archived-At: > it's a race condition while opening a file using epa-file.el to decrypt > its contents on the fly, and something else closing the buffer. Indeed, epg-decrypt-file runs filters and timers, so "anything can happen". I installed the patch below to try and address this problem, Stefan === modified file 'lisp/epa-file.el' --- lisp/epa-file.el 2013-10-28 08:04:48 +0000 +++ lisp/epa-file.el 2013-12-02 18:51:23 +0000 @@ -132,6 +132,7 @@ (error))) (local-file (or local-copy file)) (context (epg-make-context)) + (buf (current-buffer)) string length entry) (if visit (setq buffer-file-name file)) @@ -157,9 +158,10 @@ nil t)) (signal 'file-error (cons "Opening input file" (cdr error))))) - (make-local-variable 'epa-file-encrypt-to) - (setq epa-file-encrypt-to - (mapcar #'car (epg-context-result-for context 'encrypted-to))) + (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! + (setq-local epa-file-encrypt-to + (mapcar #'car (epg-context-result-for + context 'encrypted-to))) (if (or beg end) (setq string (substring string (or beg 0) end))) (save-excursion