emacs-diffs
[Top][All Lists]
Advanced

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

master d90f54db22: Avoid regexp overflow in mm-decode-content-transfer-e


From: Lars Ingebrigtsen
Subject: master d90f54db22: Avoid regexp overflow in mm-decode-content-transfer-encoding
Date: Sat, 30 Apr 2022 13:14:54 -0400 (EDT)

branch: master
commit d90f54db2285002ae969f7c685779c21eaec1605
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Avoid regexp overflow in mm-decode-content-transfer-encoding
    
    * lisp/gnus/mm-bodies.el (mm-decode-content-transfer-encoding):
    The base64 may be huge, so avoid backtracking (bug#55195).
---
 lisp/gnus/mm-bodies.el | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lisp/gnus/mm-bodies.el b/lisp/gnus/mm-bodies.el
index 956449dac1..9f2f80b472 100644
--- a/lisp/gnus/mm-bodies.el
+++ b/lisp/gnus/mm-bodies.el
@@ -191,18 +191,17 @@ If TYPE is `text/plain' CRLF->LF translation may occur."
           ((eq encoding 'base64)
            (base64-decode-region
             (point-min)
-            ;; Some mailers insert whitespace
-            ;; junk at the end which
-            ;; base64-decode-region dislikes.
-            ;; Also remove possible junk which could
-            ;; have been added by mailing list software.
             (save-excursion
+               ;; Some mailers insert whitespace junk at the end which
+              ;; base64-decode-region dislikes.
               (goto-char (point-min))
               (while (re-search-forward "^[\t ]*\r?\n" nil t)
                 (delete-region (match-beginning 0) (match-end 0)))
+              ;; Also ignore junk which could have been added by
+              ;; mailing list software by finding the final line with
+              ;; base64 text.
               (goto-char (point-max))
-              (when (re-search-backward "^[\t ]*[A-Za-z0-9+/]+=*[\t ]*$"
-                                        nil t)
+              (when (re-search-backward "[A-Za-z0-9+/]{3,3}=?[\t ]*$" nil t)
                 (forward-line))
               (point))))
           ((memq encoding '(nil 7bit 8bit binary))



reply via email to

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