]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix args-out-of-range error in epa-file-insert-file-contents
authorJunya Takahashi <jutakat@gmail.com>
Mon, 12 Apr 2021 08:14:11 +0000 (10:14 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 12 Apr 2021 08:14:48 +0000 (10:14 +0200)
* lisp/epa-file.el (epa-file-insert-file-contents): Don't bug out
on a region that's longer than the file (bug#47718).

Copyright-paperwork-exempt: yes

lisp/epa-file.el

index e46e3684c8a9b54443a732b7ec713056867582b5..33bf5adabe61c5a7ac003d0ef2a29c4a524e2f4a 100644 (file)
@@ -198,7 +198,9 @@ encryption is used."
                       (mapcar #'car (epg-context-result-for
                                      context 'encrypted-to)))
          (if (or beg end)
-             (setq string (substring string (or beg 0) end)))
+              (setq string (substring string
+                                      (or beg 0)
+                                      (and end (min end (length string))))))
          (save-excursion
            ;; If visiting, bind off buffer-file-name so that
            ;; file-locking will not ask whether we should