This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: smtpd.SMTPServer throws exception on MAIL command with no arg
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: dshockey, gvanrossum, nnorwitz
Priority: normal Keywords: patch

Created on 2007-10-21 01:51 by dshockey, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
smtpd.diff dshockey, 2007-10-21 02:25
smtpd-patch2.diff dshockey, 2007-10-23 13:00
Messages (8)
msg56616 - (view) Author: Derek Shockey (dshockey) Date: 2007-10-21 01:51
smtpd.SMTPChannel contains a bug such that when connected to an 
SMTPServer (or any subclass thereof), issuing a MAIL command with no 
argument closes the socket and gives this error on the server:

(<type 'exceptions.TypeError'>:'NoneType' object is unsubscriptable ... 
smtpd.py|__getaddr|212])

The desired result is of course is to respond with a 501 Syntax error. 
The problem arises because the arg parameter passed to each smtp_* 
command handler function is None when there is no argument. arg is 
passed on to __getaddr which attempts a slice on the None object.

A check for None in __getaddr that returns will allow the existing code 
to issue the appropriate 501 Syntax error.
msg56620 - (view) Author: Derek Shockey (dshockey) Date: 2007-10-21 02:25
Very simple patch that adds a ternary operator to skip the call to 
__getaddr if there is no arg.
msg56649 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-10-22 16:27
Thanks!

Committed revision 58594.

Is there time to backport this to 2.5.2?
msg56654 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-10-22 19:41
It would be great to get this into 2.5.2.
msg56668 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-10-23 05:35
Thanks for the patch.

Committed revision 58599. (2.5)
msg56679 - (view) Author: Derek Shockey (dshockey) Date: 2007-10-23 13:00
I'm really sorry I didn't notice this earlier, but RCPT has the same bug! 
This patch applies the same fix to that function as well.
msg56690 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-10-23 19:26
Committed revision 58618.

There better not be any others. :-)

Neal, can you add this to 2.5.2 and then close?
msg56699 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-10-24 03:53
Committed revision 58625. (2.5)
History
Date User Action Args
2022-04-11 14:56:27adminsetgithub: 45648
2007-10-24 03:53:59nnorwitzsetstatus: open -> closed
messages: + msg56699
2007-10-23 19:26:28gvanrossumsetstatus: closed -> open
assignee: gvanrossum -> nnorwitz
messages: + msg56690
2007-10-23 13:00:01dshockeysetfiles: + smtpd-patch2.diff
messages: + msg56679
2007-10-23 05:35:54nnorwitzsetstatus: open -> closed
messages: + msg56668
2007-10-22 19:41:54nnorwitzsetassignee: nnorwitz -> gvanrossum
messages: + msg56654
2007-10-22 16:27:57gvanrossumsetassignee: nnorwitz
resolution: accepted
messages: + msg56649
nosy: + gvanrossum, nnorwitz
2007-10-21 11:59:58georg.brandlsetkeywords: + patch
2007-10-21 02:25:34dshockeysetfiles: + smtpd.diff
messages: + msg56620
2007-10-21 01:51:06dshockeycreate