bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16029: 24.3.50; epa-file.el: decrypted contents get inserted into th


From: Stefan Monnier
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> 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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]