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

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

bug#4358: 23.1.50; Arithmetic overflow errors break imap


From: Stefan Monnier
Subject: bug#4358: 23.1.50; Arithmetic overflow errors break imap
Date: Wed, 09 Sep 2009 11:06:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> which (of course) shows that the imapd is sending the large value.
> Which quite simply does not make sense, as there are certainly not
> that many unseen messages in INBOX.  A quick check via telnet shows
> that the imapd does indeed reply to a STATUS INBOX (UNSEEN) command
> with that string, so I'll have to debug that.

Yes, please investigate, to try and seen if it's likely to be a common
problem, or rather a "local error".

> But it would still be nice if gnus didn't crap out when that occurs.

Yes, clearly.

> What can be done to deal with that w/o raising an exception?

Catch the exception and use another number?  In this case, I'd guess
that most-positive-fixnum would do the trick.  Tho, maybe in the general
case, our error signal could/should carry a bit more info so you'd know
whether to use most-positive-fixnum or most-negative-fixnum.

I'd suggest the patch below, tho if you could provide some more info
about your IMAP server (like name and version number), it'd be good to
add it to the comment.


        Stefan


=== modified file 'lisp/net/imap.el'
--- lisp/net/imap.el    2009-09-09 14:17:42 +0000
+++ lisp/net/imap.el    2009-09-09 15:04:06 +0000
@@ -2699,7 +2699,17 @@
                      (imap-mailbox-put 'uidvalidity (match-string 0) mailbox)
                      (goto-char (match-end 0))))
                ((string= token "UNSEEN")
-                (imap-mailbox-put 'unseen (read (current-buffer)) mailbox))
+                (imap-mailbox-put 'unseen
+                                   (condition-case err
+                                       (read (current-buffer))
+                                     ;; It seems that some IMAP servers can
+                                     ;; return very large unseen numbers,
+                                     ;; like 4294967287 (see bug#4358).
+                                     (overflow-error
+                                      ;; Don't go down without a fight.
+                                      (message "Insanely large number of 
unseen messages (%s) !!" (cadr err))
+                                      most-positive-fixnum))
+                                   mailbox))
                (t
                 (message "Unknown status data %s in mailbox %s ignored"
                          token mailbox)






reply via email to

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