summaryrefslogtreecommitdiffstats
path: root/Lib/smtpd.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-11-04 03:04:25 (GMT)
committerBarry Warsaw <barry@python.org>2001-11-04 03:04:25 (GMT)
commitebf5427bfacae1c0bc497410626cbb3e995dc214 (patch)
treeae9a0cd8e41dff348d1e48a228566efe51bb6da1 /Lib/smtpd.py
parent169ded0d6819f761def726deda19a35c91116674 (diff)
downloadcpython-ebf5427bfacae1c0bc497410626cbb3e995dc214.zip
cpython-ebf5427bfacae1c0bc497410626cbb3e995dc214.tar.gz
cpython-ebf5427bfacae1c0bc497410626cbb3e995dc214.tar.bz2
Two bug fixes for problems reported by Sverre:
__getaddr(): Watch out for empty addresses that can happen when something like "MAIL FROM:<CR>" is received. This avoids the IndexError and rightly returns an SMTP syntax error. parseargs(): We didn't handle the 2-arg case where both the localspec and the remotespec were provided on the command line.
Diffstat (limited to 'Lib/smtpd.py')
-rwxr-xr-xLib/smtpd.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index cf6821f..eb0a9b9 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -211,7 +211,9 @@ class SMTPChannel(asynchat.async_chat):
keylen = len(keyword)
if arg[:keylen].upper() == keyword:
address = arg[keylen:].strip()
- if address[0] == '<' and address[-1] == '>' and address != '<>':
+ if not address:
+ pass
+ elif address[0] == '<' and address[-1] == '>' and address != '<>':
# Addresses can be in the form <person@dom.com> but watch out
# for null address, e.g. <>
address = address[1:-1]
@@ -489,6 +491,9 @@ def parseargs():
elif len(args) < 2:
localspec = args[0]
remotespec = 'localhost:25'
+ elif len(args) < 3:
+ localspec = args[0]
+ remotespec = args[1]
else:
usage(1, 'Invalid arguments: %s' % COMMASPACE.join(args))