Issue 5949: fixed IMAP4_SSL hang when the IMAP server response is

missing proper end-of-line termination.  Patch and tests by
Scott Dial.  The new tests include a test harness which will
make it easier to add additional tests.
This commit is contained in:
R. David Murray 2009-12-09 15:15:31 +00:00
parent 29dcdabf40
commit 93321f333c
3 changed files with 170 additions and 4 deletions

View file

@ -1001,6 +1001,8 @@ class IMAP4:
raise self.abort('socket error: EOF')
# Protocol mandates all lines terminated by CRLF
if not line.endswith('\r\n'):
raise self.abort('socket error: unterminated line')
line = line[:-2]
if __debug__:
@ -1167,7 +1169,7 @@ else:
while 1:
char = self.sslobj.read(1)
line.append(char)
if char == "\n": return ''.join(line)
if char in ("\n", ""): return ''.join(line)
def send(self, data):