diff options
| author | guido | 1999-03-29 20:33:21 +0000 |
|---|---|---|
| committer | guido | 1999-03-29 20:33:21 +0000 |
| commit | 2294974e88331fdbb2754a1fe77f9fa2929e0c0d (patch) | |
| tree | 74999307aca69a932019c5ccde6790f4d00f8d1d | |
| parent | 1c8c2e6fbe495c2041ee1a1dbf2f4dc4cdc796cf (diff) | |
| download | mailman-2294974e88331fdbb2754a1fe77f9fa2929e0c0d.tar.gz mailman-2294974e88331fdbb2754a1fe77f9fa2929e0c0d.tar.zst mailman-2294974e88331fdbb2754a1fe77f9fa2929e0c0d.zip | |
| -rwxr-xr-x | Mailman/pythonlib/smtplib.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Mailman/pythonlib/smtplib.py b/Mailman/pythonlib/smtplib.py index 47e1fafbb..bd221dc4e 100755 --- a/Mailman/pythonlib/smtplib.py +++ b/Mailman/pythonlib/smtplib.py @@ -187,21 +187,30 @@ class SMTP: - server response string corresponding to response code (multiline responses are converted to a single, multiline string). + + Raises SMTPServerDisconnected if end-of-file is reached. """ resp=[] - self.file = self.sock.makefile('rb') + if self.file is None: + self.file = self.sock.makefile('rb') while 1: line = self.file.readline() + if line == '': + self.close() + raise SMTPServerDisconnected("Connection unexpectedly closed") if self.debuglevel > 0: print 'reply:', `line` resp.append(string.strip(line[4:])) code=line[:3] - #check if multiline resp + # Check that the error code is syntactically correct. + # Don't attempt to read a continuation line if it is broken. + try: + errcode = string.atoi(code) + except ValueError: + errcode = -1 + break + # Check if multiline response. if line[3:4]!="-": break - try: - errcode = string.atoi(code) - except(ValueError): - errcode = -1 errmsg = string.join(resp,"\n") if self.debuglevel > 0: |
