[offlineimap] OverflowError: Python int too large to convert to C long (#231)
Nicolas Sebrecht
notifications at github.com
Sat Aug 29 01:38:27 BST 2015
On Thu, Aug 27, 2015 at 10:48:29PM +0200, Nicolas Sebrecht wrote:
>On Thu, Aug 27, 2015 at 12:31:53PM -0700, Martin Carpella wrote:
>> Issue is caused by utime_from_header = yes for the local repository and
>> a SPAM message that is quite far in the future, exceeding int32 as
>> timestamp.
>>
>> The message's date header is:
>> Date: Thu, 03 Sep 3610 21:32:03 +0300
>>
>> Maybe a check should be added if the date is that far in the future and
>> set to native C's long max-value (depending if i386 or amd64).
>
>Aargh. This should be a rare case. I think it would be better to just
>discard the offending mail and notice the user. Playing with data type
>is annoying, code intrusive and prone to errors.
>
>Patches welcome.
OK, how about this:
--------
Handle out-of-bounds dates
Handle case where email's internal time is erroneously so large as to
cause overflow errors when setting file modification time with
utime_from_header = true.
Signed-off-by: Janna Martl <janna.martl109 at gmail.com>
---
offlineimap/folder/Maildir.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py
index 3f5c071..f969390 100644
--- a/offlineimap/folder/Maildir.py
+++ b/offlineimap/folder/Maildir.py
@@ -350,9 +350,19 @@ class MaildirFolder(BaseFolder):
tmpname = self.save_to_tmp_file(messagename, content)
if self.utime_from_header:
- date = emailutil.get_message_date(content, 'Date')
- if date != None:
- os.utime(os.path.join(self.getfullname(), tmpname), (date, date))
+ try:
+ date = emailutil.get_message_date(content, 'Date')
+ if date != None:
+ os.utime(os.path.join(self.getfullname(), tmpname),
+ (date, date))
+ # In case date is wrongly so far into the future as to be > max int32
+ except:
+ from email.Parser import Parser
+ from offlineimap.ui import getglobalui
+ datestr = Parser().parsestr(content, True).get("Date")
+ ui = getglobalui()
+ ui.warn("UID %d has invalid date %s; not changing file "\
+ "modification time" % (uid, datestr))
self.messagelist[uid] = self.msglist_item_initializer(uid)
self.messagelist[uid]['flags'] = flags
--
2.5.0
---
Reply to this email directly or view it on GitHub:
https://github.com/OfflineIMAP/offlineimap/issues/231#issuecomment-135922356
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20150828/ee77ce33/attachment-0003.html>
More information about the OfflineIMAP-project
mailing list