mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-29 10:34:42 +00:00
Limit FTP download file size.
This commit is contained in:
parent
9e1178df5c
commit
0cf22e5242
2 changed files with 6 additions and 1 deletions
|
|
@ -15,6 +15,8 @@ Changes:
|
|||
new multiline configuration syntax.
|
||||
- logging: Use codecs module for proper output encoding.
|
||||
Closes: SF bug #3114624
|
||||
- checking: The maximum file size of FTP files is now limited
|
||||
to 10MB.
|
||||
|
||||
Features:
|
||||
- gui: Store column widths in registry settings.
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ from . import proxysupport, httpurl, internpaturl, get_index_html
|
|||
from .const import WARN_FTP_MISSING_SLASH
|
||||
|
||||
DEFAULT_TIMEOUT_SECS = 300
|
||||
MAX_FTP_FILE_SIZE = 1024*1024*10 # 10MB
|
||||
|
||||
|
||||
class FtpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport):
|
||||
|
|
@ -218,10 +219,12 @@ class FtpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport):
|
|||
else:
|
||||
# download file in BINARY mode
|
||||
ftpcmd = "RETR %s" % self.filename
|
||||
# XXX limit the download size to some sane value
|
||||
buf = StringIO()
|
||||
def stor_data (s):
|
||||
"""Helper method storing given data"""
|
||||
# limit the download size
|
||||
if (buf.tell() + len(s)) > MAX_FTP_FILESIZE:
|
||||
raise LinkCheckerError(_("FTP file size too large"))
|
||||
buf.write(s)
|
||||
self.url_connection.retrbinary(ftpcmd, stor_data)
|
||||
data = buf.getvalue()
|
||||
|
|
|
|||
Loading…
Reference in a new issue