Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #421 (defect)

Opened 4 years ago

Last modified 4 years ago

Incorrect border condition in readline of SizeCheckWrapper

Status: closed (fixed)

Reported by: anonymous Assigned to: rdelon
Priority: high Milestone:
Component: CherryPy code Keywords:
Cc:

The following piece of code:

        while True:
            data = self.rfile.readline(256)
            self.bytes_read += len(data)
            self._check_length()
            res.append(data)
            if len(data) < 256:
                return ''.join(res)

should be like:

        while True:
            data = self.rfile.readline(256)
            self.bytes_read += len(data)
            self._check_length()
            res.append(data)
            if len(data) < 256 or data[-1] == '\n':
                return ''.join(res)

Reason: When self.rfile.readline(256) returns a line of exactly 256 characters including \r\n (let's call it 256line) then the original code thinks it should continue to read. This behaviour causes that the next line is getting merged with 256line and the method returns two lines merged. In case when the 256line is the last line of request's head then the merged result contains the last non empty line and the following empty line that should have indicated the end of request's head. As a result of that mimetools code keeps reading in search of an empty line indicating header's end and the web server locks up waiting for an empty line that never comes...

Greetings.

Change History

12/29/05 12:34:03: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [894].

Hosted by WebFaction

Log in as guest/cpguest to create tickets