Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
dabfc56b
Kaydet (Commit)
dabfc56b
authored
Ara 06, 2014
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
smtplib: limit amount read from the network (closes #16042)
üst
faad6bbe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
3 deletions
+41
-3
smtplib.py
Lib/smtplib.py
+9
-2
test_smtplib.py
Lib/test/test_smtplib.py
+29
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/smtplib.py
Dosyayı görüntüle @
dabfc56b
...
@@ -57,6 +57,7 @@ __all__ = ["SMTPException", "SMTPServerDisconnected", "SMTPResponseException",
...
@@ -57,6 +57,7 @@ __all__ = ["SMTPException", "SMTPServerDisconnected", "SMTPResponseException",
SMTP_PORT
=
25
SMTP_PORT
=
25
SMTP_SSL_PORT
=
465
SMTP_SSL_PORT
=
465
CRLF
=
"
\r\n
"
CRLF
=
"
\r\n
"
_MAXLINE
=
8192
# more than 8 times larger than RFC 821, 4.5.3
OLDSTYLE_AUTH
=
re
.
compile
(
r"auth=(.*)"
,
re
.
I
)
OLDSTYLE_AUTH
=
re
.
compile
(
r"auth=(.*)"
,
re
.
I
)
...
@@ -179,10 +180,14 @@ else:
...
@@ -179,10 +180,14 @@ else:
def
__init__
(
self
,
sslobj
):
def
__init__
(
self
,
sslobj
):
self
.
sslobj
=
sslobj
self
.
sslobj
=
sslobj
def
readline
(
self
):
def
readline
(
self
,
size
=-
1
):
if
size
<
0
:
size
=
None
str
=
""
str
=
""
chr
=
None
chr
=
None
while
chr
!=
"
\n
"
:
while
chr
!=
"
\n
"
:
if
size
is
not
None
and
len
(
str
)
>=
size
:
break
chr
=
self
.
sslobj
.
read
(
1
)
chr
=
self
.
sslobj
.
read
(
1
)
if
not
chr
:
if
not
chr
:
break
break
...
@@ -353,7 +358,7 @@ class SMTP:
...
@@ -353,7 +358,7 @@ class SMTP:
self
.
file
=
self
.
sock
.
makefile
(
'rb'
)
self
.
file
=
self
.
sock
.
makefile
(
'rb'
)
while
1
:
while
1
:
try
:
try
:
line
=
self
.
file
.
readline
()
line
=
self
.
file
.
readline
(
_MAXLINE
+
1
)
except
socket
.
error
as
e
:
except
socket
.
error
as
e
:
self
.
close
()
self
.
close
()
raise
SMTPServerDisconnected
(
"Connection unexpectedly closed: "
raise
SMTPServerDisconnected
(
"Connection unexpectedly closed: "
...
@@ -363,6 +368,8 @@ class SMTP:
...
@@ -363,6 +368,8 @@ class SMTP:
raise
SMTPServerDisconnected
(
"Connection unexpectedly closed"
)
raise
SMTPServerDisconnected
(
"Connection unexpectedly closed"
)
if
self
.
debuglevel
>
0
:
if
self
.
debuglevel
>
0
:
print
>>
stderr
,
'reply:'
,
repr
(
line
)
print
>>
stderr
,
'reply:'
,
repr
(
line
)
if
len
(
line
)
>
_MAXLINE
:
raise
SMTPResponseException
(
500
,
"Line too long."
)
resp
.
append
(
line
[
4
:]
.
strip
())
resp
.
append
(
line
[
4
:]
.
strip
())
code
=
line
[:
3
]
code
=
line
[:
3
]
# Check that the error code is syntactically correct.
# Check that the error code is syntactically correct.
...
...
Lib/test/test_smtplib.py
Dosyayı görüntüle @
dabfc56b
...
@@ -292,6 +292,33 @@ class BadHELOServerTests(unittest.TestCase):
...
@@ -292,6 +292,33 @@ class BadHELOServerTests(unittest.TestCase):
HOST
,
self
.
port
,
'localhost'
,
3
)
HOST
,
self
.
port
,
'localhost'
,
3
)
@unittest.skipUnless
(
threading
,
'Threading required for this test.'
)
class
TooLongLineTests
(
unittest
.
TestCase
):
respdata
=
'250 OK'
+
(
'.'
*
smtplib
.
_MAXLINE
*
2
)
+
'
\n
'
def
setUp
(
self
):
self
.
old_stdout
=
sys
.
stdout
self
.
output
=
StringIO
.
StringIO
()
sys
.
stdout
=
self
.
output
self
.
evt
=
threading
.
Event
()
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
sock
.
settimeout
(
15
)
self
.
port
=
test_support
.
bind_port
(
self
.
sock
)
servargs
=
(
self
.
evt
,
self
.
respdata
,
self
.
sock
)
threading
.
Thread
(
target
=
server
,
args
=
servargs
)
.
start
()
self
.
evt
.
wait
()
self
.
evt
.
clear
()
def
tearDown
(
self
):
self
.
evt
.
wait
()
sys
.
stdout
=
self
.
old_stdout
def
testLineTooLong
(
self
):
self
.
assertRaises
(
smtplib
.
SMTPResponseException
,
smtplib
.
SMTP
,
HOST
,
self
.
port
,
'localhost'
,
3
)
sim_users
=
{
'Mr.A@somewhere.com'
:
'John A'
,
sim_users
=
{
'Mr.A@somewhere.com'
:
'John A'
,
'Ms.B@somewhere.com'
:
'Sally B'
,
'Ms.B@somewhere.com'
:
'Sally B'
,
'Mrs.C@somewhereesle.com'
:
'Ruth C'
,
'Mrs.C@somewhereesle.com'
:
'Ruth C'
,
...
@@ -526,7 +553,8 @@ class SMTPSimTests(unittest.TestCase):
...
@@ -526,7 +553,8 @@ class SMTPSimTests(unittest.TestCase):
def
test_main
(
verbose
=
None
):
def
test_main
(
verbose
=
None
):
test_support
.
run_unittest
(
GeneralTests
,
DebuggingServerTests
,
test_support
.
run_unittest
(
GeneralTests
,
DebuggingServerTests
,
NonConnectingTests
,
NonConnectingTests
,
BadHELOServerTests
,
SMTPSimTests
)
BadHELOServerTests
,
SMTPSimTests
,
TooLongLineTests
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_main
()
test_main
()
Misc/NEWS
Dosyayı görüntüle @
dabfc56b
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.9?
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.9?
Library
Library
-------
-------
- Issue #16042: CVE-2013-1752: smtplib: Limit amount of data read by limiting
the call to readline(). Original patch by Christian Heimes.
- Issue #16041: In poplib, limit maximum line length read from the server to
- Issue #16041: In poplib, limit maximum line length read from the server to
prevent CVE-2013-1752.
prevent CVE-2013-1752.
...
...
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