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
b3ac8432
Kaydet (Commit)
b3ac8432
authored
Eki 12, 2014
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#16040: fix unlimited read from connection in nntplib.
üst
f84422da
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
nntplib.py
Lib/nntplib.py
+10
-1
test_nntplib.py
Lib/test/test_nntplib.py
+10
-0
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/nntplib.py
Dosyayı görüntüle @
b3ac8432
...
...
@@ -85,6 +85,13 @@ __all__ = ["NNTP",
"decode_header"
,
]
# maximal line length when calling readline(). This is to prevent
# reading arbitrary lenght lines. RFC 3977 limits NNTP line length to
# 512 characters, including CRLF. We have selected 2048 just to be on
# the safe side.
_MAXLINE
=
2048
# Exceptions raised when an error or invalid response is received
class
NNTPError
(
Exception
):
"""Base class for all nntplib exceptions"""
...
...
@@ -410,7 +417,9 @@ class _NNTPBase:
"""Internal: return one line from the server, stripping _CRLF.
Raise EOFError if the connection is closed.
Returns a bytes object."""
line
=
self
.
file
.
readline
()
line
=
self
.
file
.
readline
(
_MAXLINE
+
1
)
if
len
(
line
)
>
_MAXLINE
:
raise
NNTPDataError
(
'line too long'
)
if
self
.
debugging
>
1
:
print
(
'*get*'
,
repr
(
line
))
if
not
line
:
raise
EOFError
...
...
Lib/test/test_nntplib.py
Dosyayı görüntüle @
b3ac8432
...
...
@@ -563,6 +563,11 @@ class NNTPv1Handler:
<a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>
<f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>
."""
)
elif
(
group
==
'comp.lang.python'
and
date_str
in
(
'20100101'
,
'100101'
)
and
time_str
==
'090000'
):
self
.
push_lit
(
'too long line'
*
3000
+
'
\n
.'
)
else
:
self
.
push_lit
(
"""
\
230 An empty list of newsarticles follows
...
...
@@ -1158,6 +1163,11 @@ class NNTPv1v2TestsMixin:
self
.
assertEqual
(
cm
.
exception
.
response
,
"435 Article not wanted"
)
def
test_too_long_lines
(
self
):
dt
=
datetime
.
datetime
(
2010
,
1
,
1
,
9
,
0
,
0
)
self
.
assertRaises
(
nntplib
.
NNTPDataError
,
self
.
server
.
newnews
,
"comp.lang.python"
,
dt
)
class
NNTPv1Tests
(
NNTPv1v2TestsMixin
,
MockedNNTPTestsMixin
,
unittest
.
TestCase
):
"""Tests an NNTP v1 server (no capabilities)."""
...
...
Misc/NEWS
Dosyayı görüntüle @
b3ac8432
...
...
@@ -16,6 +16,10 @@ Core and Builtins
Library
-------
- Issue #16040: CVE-2013-1752: nntplib: Limit maximum line lengths to 2048 to
prevent readline() calls from consuming too much memory. Patch by Jyrki
Pulliainen.
- Issue #16039: CVE-2013-1752: Change use of readline in imaplib module to limit
line length. Patch by Emil Lind.
...
...
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