Remove all MODSEQ entries before parsing to avoid integer overflows.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Tue, 15 Mar 2011 16:52:42 +0000 (17:52 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Tue, 15 Mar 2011 16:52:42 +0000 (17:52 +0100)
lisp/ChangeLog
lisp/nnimap.el

index 8908666..d27e98c 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-15  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * nnimap.el (nnimap-parse-flags): Remove all MODSEQ entries before
+       parsing to avoid integer overflows.
+
 2011-03-15  Nelson Ferreira  <nelson.ferreira@ieee.org>  (tiny change)
 
        * gnus-art.el (gnus-article-treat-body-boundary): Fix boundary width on
index 11c521f..36d8c95 100644 (file)
@@ -1505,20 +1505,14 @@ textual parts.")
                (setq start end))
            (setq start (point))
            (goto-char end))
+         ;; Remove any MODSEQ entries in the buffer, because they may
+         ;; contain numbers that are too large for 32-bit Emacsen.
+         (save-excursion
+           (while (re-search-forward " MODSEQ ([0-9]+)" nil t)
+             (replace-match "" t t)))
          (while (re-search-forward "^\\* [0-9]+ FETCH " start t)
            (let ((p (point)))
-             ;; FIXME: For FETCH lines like "* 2971 FETCH (FLAGS (%Recent) UID
-             ;; 12509 MODSEQ (13419098521433281274))" we get an
-             ;; overflow-error.  The handler simply deletes that large number
-             ;; and reads again.  But maybe there's a better fix...
-             (setq elems (condition-case nil (read (current-buffer))
-                           (overflow-error
-                            ;; After an overflow-error, point is just after
-                            ;; the too large number.  So delete it and try
-                            ;; again.
-                            (delete-region (point) (progn (backward-word) (point)))
-                            (goto-char p)
-                            (read (current-buffer)))))
+             (setq elems (read (current-buffer)))
              (push (cons (cadr (memq 'UID elems))
                          (cadr (memq 'FLAGS elems)))
                    articles)))