Issue #16039: CVE-2013-1752: Change use of readline in imaplib module to limit

line length.  Patch by Emil Lind.
This commit is contained in:
Georg Brandl 2013-10-27 06:52:14 +01:00
parent 246eb11058
commit ca580f4ec1
3 changed files with 31 additions and 4 deletions

View file

@ -325,6 +325,17 @@ class BaseThreadedNetworkedTests(unittest.TestCase):
self.assertEqual(ret, "OK")
def test_linetoolong(self):
class TooLongHandler(SimpleIMAPHandler):
def handle(self):
# Send a very long response line
self.wfile.write(b'* OK ' + imaplib._MAXLINE*b'x' + b'\r\n')
with self.reaped_server(TooLongHandler) as server:
self.assertRaises(imaplib.IMAP4.error,
self.imap_class, *server.server_address)
class ThreadedNetworkedTests(BaseThreadedNetworkedTests):
server_class = socketserver.TCPServer