A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/c9cb18d3f7e5bf03220c213183ff0caa75905bdd below:

Limit amount of data read by · python/cpython@c9cb18d · GitHub

49 49 50 50

# The standard FTP server control port

51 51

FTP_PORT = 21

52 +

# The sizehint parameter passed to readline() calls

53 +

MAXLINE = 8192

52 54 53 55 54 56

# Exception raised when an error or invalid response is received

@@ -96,6 +98,7 @@ class FTP:

96 98

debugging = 0

97 99

host = ''

98 100

port = FTP_PORT

101 +

maxline = MAXLINE

99 102

sock = None

100 103

file = None

101 104

welcome = None

@@ -190,7 +193,9 @@ def putcmd(self, line):

190 193

# Internal: return one line from the server, stripping CRLF.

191 194

# Raise EOFError if the connection is closed

192 195

def getline(self):

193 -

line = self.file.readline()

196 +

line = self.file.readline(self.maxline + 1)

197 +

if len(line) > self.maxline:

198 +

raise Error("got more than %d bytes" % self.maxline)

194 199

if self.debugging > 1:

195 200

print('*get*', self.sanitize(line))

196 201

if not line: raise EOFError

@@ -444,7 +449,9 @@ def retrlines(self, cmd, callback = None):

444 449

with self.transfercmd(cmd) as conn, \

445 450

conn.makefile('r', encoding=self.encoding) as fp:

446 451

while 1:

447 -

line = fp.readline()

452 +

line = fp.readline(self.maxline + 1)

453 +

if len(line) > self.maxline:

454 +

raise Error("got more than %d bytes" % self.maxline)

448 455

if self.debugging > 2: print('*retr*', repr(line))

449 456

if not line:

450 457

break

@@ -494,7 +501,9 @@ def storlines(self, cmd, fp, callback=None):

494 501

self.voidcmd('TYPE A')

495 502

with self.transfercmd(cmd) as conn:

496 503

while 1:

497 -

buf = fp.readline()

504 +

buf = fp.readline(self.maxline + 1)

505 +

if len(buf) > self.maxline:

506 +

raise Error("got more than %d bytes" % self.maxline)

498 507

if not buf: break

499 508

if buf[-2:] != B_CRLF:

500 509

if buf[-1] in B_CRLF: buf = buf[:-1]

@@ -741,7 +750,9 @@ def retrlines(self, cmd, callback = None):

741 750

fp = conn.makefile('r', encoding=self.encoding)

742 751

try:

743 752

while 1:

744 -

line = fp.readline()

753 +

line = fp.readline(self.maxline + 1)

754 +

if len(line) > self.maxline:

755 +

raise Error("got more than %d bytes" % self.maxline)

745 756

if self.debugging > 2: print('*retr*', repr(line))

746 757

if not line:

747 758

break

@@ -779,7 +790,9 @@ def storlines(self, cmd, fp, callback=None):

779 790

conn = self.transfercmd(cmd)

780 791

try:

781 792

while 1:

782 -

buf = fp.readline()

793 +

buf = fp.readline(self.maxline + 1)

794 +

if len(buf) > self.maxline:

795 +

raise Error("got more than %d bytes" % self.maxline)

783 796

if not buf: break

784 797

if buf[-2:] != B_CRLF:

785 798

if buf[-1] in B_CRLF: buf = buf[:-1]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4