From 8ea4bf81f7c7e74cbe6c654051ae021e683417e5 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 15 Jul 2015 14:18:08 +0200 Subject: [PATCH] [FIX] fetchmail: workaround poplib line length bug In order to fix Python bug https://bugs.python.org/issue16041 a maximum line length was introduced in poplib when reading email contents from the POP3 server. That limit is set to prevent DoS attacks via malicious POP3 servers. The default limit (2048) seems to be too low for emails commonly found on the internet, retrieved via POP3 from popular mail services such as GMail, Hotmail, etc. (The POP3 servers might send back the lines verbatim without splitting them up) This is discussed in follow-up Python bug https://bugs.python.org/issue23906. Workaround implemented by forcing a higher default limit to accomodate POP3 responses with lines up to 64KB. --- addons/fetchmail/fetchmail.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 0a27a05b275..84e48c794fd 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -20,6 +20,7 @@ ############################################################################## import logging +import poplib import time from imaplib import IMAP4 from imaplib import IMAP4_SSL @@ -42,6 +43,9 @@ from openerp.tools.translate import _ _logger = logging.getLogger(__name__) MAX_POP_MESSAGES = 50 +# Workaround for Python 2.7.8 bug https://bugs.python.org/issue23906 +poplib._MAXLINE = 65536 + class fetchmail_server(osv.osv): """Incoming POP/IMAP mail server account""" _name = 'fetchmail.server'