Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9cf5ef4c
Commit
9cf5ef4c
authored
Aug 23, 2010
by
Giampaolo Rodolà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue 9129: adds proper error handling on accept() when smtpd accepts new incoming connections.
parent
bbc4782d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
Lib/smtpd.py
Lib/smtpd.py
+23
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/smtpd.py
View file @
9cf5ef4c
...
@@ -121,7 +121,15 @@ class SMTPChannel(asynchat.async_chat):
...
@@ -121,7 +121,15 @@ class SMTPChannel(asynchat.async_chat):
self
.
rcpttos
=
[]
self
.
rcpttos
=
[]
self
.
received_data
=
''
self
.
received_data
=
''
self
.
fqdn
=
socket
.
getfqdn
()
self
.
fqdn
=
socket
.
getfqdn
()
self
.
peer
=
conn
.
getpeername
()
try
:
self
.
peer
=
conn
.
getpeername
()
except
socket
.
error
as
err
:
# a race condition may occur if the other end is closing
# before we can get the peername
self
.
close
()
if
err
.
args
[
0
]
!=
errno
.
ENOTCONN
:
raise
return
print
(
'Peer:'
,
repr
(
self
.
peer
),
file
=
DEBUGSTREAM
)
print
(
'Peer:'
,
repr
(
self
.
peer
),
file
=
DEBUGSTREAM
)
self
.
push
(
'220 %s %s'
%
(
self
.
fqdn
,
__version__
))
self
.
push
(
'220 %s %s'
%
(
self
.
fqdn
,
__version__
))
self
.
set_terminator
(
b'
\
r
\
n
'
)
self
.
set_terminator
(
b'
\
r
\
n
'
)
...
@@ -414,7 +422,20 @@ class SMTPServer(asyncore.dispatcher):
...
@@ -414,7 +422,20 @@ class SMTPServer(asyncore.dispatcher):
localaddr
,
remoteaddr
),
file
=
DEBUGSTREAM
)
localaddr
,
remoteaddr
),
file
=
DEBUGSTREAM
)
def
handle_accept
(
self
):
def
handle_accept
(
self
):
conn
,
addr
=
self
.
accept
()
try
:
conn
,
addr
=
self
.
accept
()
except
TypeError
:
# sometimes accept() might return None
return
except
socket
.
error
as
err
:
# ECONNABORTED might be thrown
if
err
.
args
[
0
]
!=
errno
.
ECONNABORTED
:
raise
return
else
:
# sometimes addr == None instead of (ip, port)
if
addr
==
None
:
return
print
(
'Incoming connection from %s'
%
repr
(
addr
),
file
=
DEBUGSTREAM
)
print
(
'Incoming connection from %s'
%
repr
(
addr
),
file
=
DEBUGSTREAM
)
channel
=
self
.
channel_class
(
self
,
conn
,
addr
)
channel
=
self
.
channel_class
(
self
,
conn
,
addr
)
...
...
Misc/NEWS
View file @
9cf5ef4c
...
@@ -123,6 +123,9 @@ Extensions
...
@@ -123,6 +123,9 @@ Extensions
Library
Library
-------
-------
- Issue #9129: smtpd.py is vulnerable to DoS attacks deriving from missing
error handling when accepting a new connection.
- Issue #9601: ftplib now provides a workaround for non-compliant
- Issue #9601: ftplib now provides a workaround for non-compliant
implementations such as IIS shipped with Windows server 2003 returning invalid
implementations such as IIS shipped with Windows server 2003 returning invalid
response codes for MKD and PWD commands.
response codes for MKD and PWD commands.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment