GNU bug report logs - #16029
24.3.50; epa-file.el: decrypted contents get inserted into the wrong buffer

Previous Next

Package: emacs;

Reported by: Attila Lendvai <attila.lendvai <at> gmail.com>

Date: Mon, 2 Dec 2013 16:52:02 UTC

Severity: normal

Found in version 24.3.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 16029-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Attila Lendvai <attila.lendvai <at> gmail.com>
Cc: 16029-done <at> debbugs.gnu.org
Subject: Re: 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
> 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





This bug report was last modified 11 years and 170 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.